ARTICLE: "number-strings""Converting between numbers and strings"
"These words only convert between real numbers and strings. Complex numbers are constructed by the parser (" { $link "parser" } ") and printed by the prettyprinter (" { $link "prettyprint" } ")."
{ $description "Converts a sequence of digits (with most significant digit first) into an integer." }
{ $notes "This is one of the factors of " { $link string>number } "." } ;
HELP:>digit
{ $values { "n""an integer between 0 and 35" } { "ch""a character" } }
{ $description "Outputs a character representation of a digit." }
{ $notes "This is one of the factors of " { $link number>string } "." } ;
HELP:digit>
{ $values { "ch""a character" } { "n"integer } }
{ $description "Converts a character representation of a digit to an integer." }
{ $notes "This is one of the factors of " { $link string>number } "." } ;
HELP:base>
{ $values { "str"string } { "radix""an integer between 2 and 36" } { "n/f""a real number or " { $link f } } }
{ $description "Creates a real number from a string representation with the given radix. The radix is ignored for floating point literals; they are always taken to be in base 10."
$nl
"Outputs " { $link f } " if the string does not represent a number." } ;
{ >base base> } related-words
HELP:string>number
{ $values { "str"string } { "n/f""a real number or " { $link f } } }
{ $description "Creates a real number from a string representation of a number in base 10."
$nl
"Outputs " { $link f } " if the string does not represent a number." } ;
{ string>number number>string } related-words
HELP:bin>
{ $values { "str"string } { "n/f""a real number or " { $link f } } }
{ $description "Creates a real number from a string representation of a number in base 2."
$nl
"Outputs " { $link f } " if the string does not represent a number." } ;
{ $values { "n"real } { "radix""an integer between 2 and 36" } { "str"string } }
{ $description "Converts a real number into a string representation using the given radix. If the number is a float, the radix is ignored and the output is always in base 10." } ;
HELP:>bin
{ $values { "n"real } { "str"string } }
{ $description "Outputs a string representation of a number using base 2." } ;
HELP:>oct
{ $values { "n"real } { "str"string } }
{ $description "Outputs a string representation of a number using base 8." } ;