From 91f0109db79326c2126a1950e28cb3c027c872c1 Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Fri, 6 Dec 1996 17:14:56 +0000 Subject: [PATCH] Initial revision --- etc/r2bs.scm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 etc/r2bs.scm diff --git a/etc/r2bs.scm b/etc/r2bs.scm new file mode 100644 index 000000000..cf092b89d --- /dev/null +++ b/etc/r2bs.scm @@ -0,0 +1,19 @@ +;; $Id: r2bs.scm,v 1.1 1996/12/06 17:14:56 adams Exp $ + +(define (real->bit-string x) + ;; Allocate a 64-bit result to hold the double-precision number. + (let ((result (bit-string-allocate 64))) + (read-bits! + ;; Guarantee that the number is floating-point. + (exact->inexact x) + ;; Skip over the non-marked vector header (32 bits). + 32 + result) + result)) + +(define (bit-string->flonum bs) + ;; Allocate a flonum that we can clobber. + ;; The call to `random' prevents the compiler from constant folding. + (let ((flonum (exact->inexact (random 1)))) + (write-bits! flonum 32 bs) + flonum)) -- 2.25.1