11.3.136 number_codes/2 [ISO]

Synopsis

number_codes(+Number, -Codes)

number_codes(-Number, +Codes)

Codes is the codes comprising the printed representation of Number.

Arguments

Number
number
Codes
codes

Description

Initially, either Number must be instantiated to a number, or Codes must be instantiated to a proper codes.

If Number is initially instantiated to a number, Codes will be unified with the codes that make up its printed representation.

If Number is uninstantiated and Codes is initially instantiated to a codes that corresponds to the correct syntax of a number, Number will be bound to that number; otherwise number_codes/2 will simply fail.

Exceptions

instantiation_error
Number and Codes are both uninstantiated
type_error
Number is not a number or Codes is not a list
domain_error
Codes is not a codes
representation_error
Codes is a list corresponding to a number that can't be represented
syntax_error
Chars does not correspond to a syntactically valid number

Examples

     | ?- number_codes(foo, L).
     
     no
     | ?- number_codes(431, L).
     
     L = [52,51,49]
     | ?- number_codes(X, [102,111,111]).
     
     no
     | ?- number_codes(X, [52,51,49]).
     
     X = 431
     | ?- number_codes(X, "15.0e+12").
     
     X = 1.5e+13

See Also

number_chars/2.


Send feedback on this subject.