racket/fasl: fixed representation for +nan.0
To make fasl writing as determinsitic and portable as possible, write +nan.0 and +nan.f always with a specific bit pattern. This choice risks losing information that is potentially useful, but given the way that Racket treats all NaN encodings as equivalent, that rick seems low.
This commit is contained in:
parent
6a35d64e95
commit
e79f07b6cc
|
@ -195,10 +195,18 @@
|
||||||
(write-fasl-integer v o)])]
|
(write-fasl-integer v o)])]
|
||||||
[(flonum? v)
|
[(flonum? v)
|
||||||
(write-byte fasl-flonum-type o)
|
(write-byte fasl-flonum-type o)
|
||||||
(write-bytes (real->floating-point-bytes v 8 #f) o)]
|
(write-bytes (if (eqv? v +nan.0)
|
||||||
|
;; use a canonical NaN (0 mantissa)
|
||||||
|
#"\0\0\0\0\0\0\370\177"
|
||||||
|
(real->floating-point-bytes v 8 #f))
|
||||||
|
o)]
|
||||||
[(single-flonum? v)
|
[(single-flonum? v)
|
||||||
(write-byte fasl-single-flonum-type o)
|
(write-byte fasl-single-flonum-type o)
|
||||||
(write-bytes (real->floating-point-bytes v 4 #f) o)]
|
(write-bytes (if (eqv? v +nan.f)
|
||||||
|
;; use a canonical NaN (0 mantissa)
|
||||||
|
#"\0\0\300\177"
|
||||||
|
(real->floating-point-bytes v 4 #f))
|
||||||
|
o)]
|
||||||
[(extflonum? v)
|
[(extflonum? v)
|
||||||
(write-byte fasl-extflonum-type o)
|
(write-byte fasl-extflonum-type o)
|
||||||
(define bstr (string->bytes/utf-8 (format "~a" v)))
|
(define bstr (string->bytes/utf-8 (format "~a" v)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user