Converting between numbers and strings

Factor handbook » The language » Numbers

Factor handbook » The language » Numbers

Prev: | Mathematical functions |

Next: | Integers |

These words only convert between real numbers and strings. Complex numbers are constructed by the parser ( The parser ) and printed by the prettyprinter ( The prettyprinter ).

Integers can be converted to and from arbitrary bases. Floating point numbers can only be converted to and from base 10 and 16.

Converting numbers to strings:

Converting strings to numbers:

You can also input literal numbers in a different base ( Integer syntax ).

See also

Prettyprinting numbers

Integers can be converted to and from arbitrary bases. Floating point numbers can only be converted to and from base 10 and 16.

Converting numbers to strings:

number>string ( n -- str )

>bin ( n -- str )

>oct ( n -- str )

>hex ( n -- str )

>base ( n radix -- str )

Converting strings to numbers:

string>number ( str -- n/f )

bin> ( str -- n/f )

oct> ( str -- n/f )

hex> ( str -- n/f )

base> ( str radix -- n/f )

You can also input literal numbers in a different base ( Integer syntax ).

See also

Prettyprinting numbers

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.99 x86.64 (2203, heads/master-424edf64aa, Mar 8 2023 13:48:50)