Converting between numbers and strings
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:
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