
Andrew Coppin
Jon Fairbairn wrote:
"David House"
writes: On 31/05/07, Andrew Coppin
wrote: If you're bored... can you come up with a solution to this?
Try using floatToDigits: http://haskell.org/ghc/docs/latest/html/libraries/base/Numeric.html#v%3Afloa...
"floatToDigits takes a base and a non-negative RealFloat number, and returns a list of digits and an exponent."
I think you also need floatRadix and floatDigits.
Note that the challenge asks for the "internal" bitmap representation of an IEEE double-precision integer - not the mathematical binary expansion.
Hence my remark above.
(In particular, things like Infinity and NaN have special bit sequences.)
Did I mention that this is a silly challange yet?
Yes, but you didn't say that it's not only silly but demonstrates the opposite of expressiveness as it's all about breaking an abstraction and must be non-portable code (because it's definition is that it won't give the same results on different hardware), so such code should be *hard* to write in a good language. -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2007-05-07)