number->string -- r7rs Definition converter;
number->string (from vonuvoli);Procedure variants:
((number) -> (string-not-empty))
number;string-not-empty;((number number-radix) -> (string-not-empty))
number;number-radix;string-not-empty;scheme:base -- (scheme base);scheme -- (scheme);(number->string z) (number->string z radix)Domain: It is an error if
radixis not one of2,8,10, or16.The procedure
number->stringtakes a number and a radix and returns as a string an external representation of the given number in the given radix such that(let ((number number) (radix radix)) (eqv? number (string->number (number->string number radix) radix)))is true. It is an error if no possible result makes this expression true. If omitted,
radixdefaults to10.If
zis inexact, the radix is10, and the above expression can be satisfied by a result that contains a decimal point, then the result contains a decimal point and is expressed using the minimum number of digits (exclusive of exponent and trailing zeroes) needed to make the above expression true; otherwise the format of the result is unspecified.The result returned by
number->stringnever contains an explicit radix prefix.Note: The error case can occur only when
zis not a complex number or is a complex number with a non-rational real or imaginary part.Rationale: If
zis an inexact number and the radix is10, then the above expression is normally satisfied by a result containing a decimal point. The unspecified case allows for infinities,NaNs, and unusual representations.
The text herein was sourced and adapted as described in the "R7RS attribution of various text snippets" appendix.