number_chars/2
number_chars(
+Number,
-Chars)
number_chars(
-Number,
+Chars)
Chars is the list consisting of the ASCII character codes comprising the printed representation of Number.
Chars is the list of ASCII character codes comprising the printed representation of Number.
Initially, either Number must be instantiated to a number, or Chars must be instantiated to a proper list of character codes (containing no variables).
If Number is initially instantiated to a number, Chars will be unified with the list of character codes that make up its printed representation.
If Number is uninstantiated and Chars is initially
instantiated to a list of characters that corresponds to the correct
syntax of a number (either integer or float), Number will be
bound to that number; otherwise number_chars/2
will simply fail.
instantiation_error
domain_error
type_error
representation_error
| ?- number_chars(foo, L). no
| ?- number_chars(431, L). L = [52,51,49]
| ?- number_chars(X, [102,111,111]). no
| ?- number_chars(X, [52,51,49]). X = 431
| ?- number_chars(X, "15.0e+12"). X = 1.5e+13
atom_chars/2