[Haskell-cafe] Re: Just for a laugh...

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Thu May 31 16:52:33 EDT 2007


Andrew Coppin <andrewcoppin at btinternet.com> writes:

> Jon Fairbairn wrote:
> > "David House" <dmhouse at gmail.com> writes:
> >
> >
> >> On 31/05/07, Andrew Coppin <andrewcoppin at btinternet.com> 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%3AfloatToDigits
> >>
> >> "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 at cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2007-05-07)



More information about the Haskell-Cafe mailing list