This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see Nan in WG2's repo for R7RS-large.

Nan

cowan
2012-05-17 03:51:23
2history
source

R6RS

These are the R6RS examples involving NaNs (already accounted for verbally in the "Implementation extensions" section of R7RS):

(number? +nan.0) => #t ; NaN is real but not rational (complex? +nan.0) => #t (real? +nan.0) => #t (rational? +nan.0) => #f ; NaN compares #f to anything (= +nan.0 z) => #f where z numeric (< +nan.0 x) => #f where x real (> +nan.0 x) => #f where x real (zero? +nan.0) => #f ; NaN is unsigned (positive? +nan.0) => #f (negative? +nan.0) => #f ; NaN is mostly sticky (* 0 +inf.0) => 0 or +nan.0 (* 0 +nan.0) => 0 or +nan.0 (+ +nan.0 x) => +nan.0 where x real (* +nan.0 x) => +nan.0 where x real and not exact 0 ; Sum of +inf.0 and -inf.0 is NaN (+ +inf.0 -inf.0) => +nan.0 (- +inf.0 +inf.0) => +nan.0 ; 0/0 is NaN unless both 0s are exact (/ 0 0.0) => +nan.0 (/ 0.0 0) => +nan.0 (/ 0.0 0.0) => +nan.0 (round +nan.0) => +nan.0 ; Nan rounds (etc.) to NaN (rationalize +inf.0 +inf.0) => +nan.0 ; Rationalizing infinity to nearest infinity is NaN

Implementations

Racket, Gauche, MIT, Chicken, Guile, Chez, Ikarus, Larceny, Ypsilon, STklos all support +nan.0 and -nan.0 as equivalent forms. Bigloo, Scheme48/scsh, SISC, SCM, Scheme 9 don't support either form. Gambit and Chibi support +nan.0 but not -nan.0.