does anyone know about an existing implementation of a procedure, say `real->binary64', that takes a Scheme real number `x' and returns a bytevector containing the binary64 representation (in any endianess) of an IEEE 754 double, which is closest to `x'?
In particular, for a Scheme system whose inexact reals are implemented using IEEE doubles, this procedure should be a bijection (perhaps modulo NaNs).
On Monday, October 7, 2019 at 4:17:41 PM UTC-4, Marc Nieper-Wißkirchen wrote:x'?
does anyone know about an existing implementation of a procedure, say `real->binary64', that takes a Scheme real number `x' and returns a bytevector containing the binary64 representation (in any endianess) of an IEEE 754 double, which is closest to `
so does Chicken; both of them are trivial.In particular, for a Scheme system whose inexact reals are implemented using IEEE doubles, this procedure should be a bijection (perhaps modulo NaNs).
There's a portable implementation at https://github.com/scheme-requests-for-implementation/srfi-4/blob/master/contrib/cowan/r6rs/bytevectors-impl.scm. It's not very efficient unless you have a fast compiler, though. Chibi has a C implementation and
--
John Cowan http://vrici.lojban.org/~cowan cowan@ccil.org
One Word to write them all / One Access to find them,
One Excel to count them all / And thus to Windows bind them.
--Mike Champion
does anyone know about an existing implementation of a procedure, say `real->binary64', that takes a Scheme real number `x' and returns a bytevector containing the binary64 representation (in any endianess) of an IEEE 754 double, which is closest to `x'?
Hi,?
does anyone know about an existing implementation of a procedure, say `real->binary64', that takes a Scheme real number `x' and returns a bytevector containing the binary64 representation (in any endianess) of an IEEE 754 double, which is closest to `x'
In particular, for a Scheme system whose inexact reals are implemented using IEEE doubles, this procedure should be a bijection (perhaps modulo NaNs).
Thanks for looking into it.
-- Marc
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 66:31:09 |
Calls: | 6,654 |
Files: | 12,200 |
Messages: | 5,331,881 |