real->inexact high-level implementation added by sytse on Thu Oct 11 20:51:50 2018
($define! real->inexact
($λ (real)
($if (inexact? real) real
(zero? real) 0.0
($let* ((absolute (abs real))
;; When absolute = 1, it doesn't matter: pick
;; the lowest of the two.
(exponent ($if (>=? absolute 1)
(- (integer-length (floor absolute)) 53)
(max -1074 (- -52 (integer-length (floor (/ 1 absolute)))))))
(scaled (* real (expt 2 (- 0 exponent))))
(significand (round-quotient (numerator scaled)
(denominator scaled))))
(* (expt 2.0 exponent) significand)))))