- flonum-print-precision #!optional PRECISIONprocedure
Gets and sets the number of significant digits printed for a floating-point number. PRECISION must be a positive fixnum. Returns the setting that was previously in effect.
The default print precision is 15 on nearly all systems, and 7 on the rare system on which the double type is only single-precision.
Note: To ensure read/write invariance for all floating-point numbers, you must increase print precision from 15 to 17 (or from 7 to 9). For example:
> (define a (expt 2 -53)) > (define b (+ a (* 2 (expt 10 -32)))) > (eqv? a b) #f > (flonum-print-precision 15) > (cons a b) (1.11022302462516e-16 . 1.11022302462516e-16) ;; same printed representation > (flonum-print-precision 17) > (cons a b) (1.1102230246251565e-16 . 1.1102230246251568e-16) ;; differs in last place
On the downside, this will result in unnecessarily precise representations of many numbers:
> (flonum-print-precision 17) > 0.1 0.10000000000000001
The maximum number of decimal digits required to uniquely represent all floating-point numbers of a certain precision is given by the formula ceil(1+N*log10(2)), where N is the number of bits of precision; for double-precision, N=53.