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

Udo Stenzel u.stenzel at web.de
Sat Jun 2 07:30:02 EDT 2007

Andrew Coppin wrote:
> Note that the challenge asks for the "internal" bitmap representation of 
> an IEEE double-precision integer

Actually it didn't.  It asked for the machine's internal representation
of a double precision float, and you are not guaranteed that this
representation conforms to IEEE 7-whatsit.  It is beyond me what you're
going to do with that unspecified representation, though.

> Did I mention that this is a silly challange yet?

Silly, yes.  Challenge, no.  We can do the same the C++ guy did, it's
only a question if we need to.  Something close to this:

| import Foreign.Marshal
| import Foreign.Ptr
| import Data.Word
| valueToBytes :: Storable a => a -> IO [Word8]
| valueToBytes a = with a $ \p -> peekBytes (castPtr b) (sizeOf a)

Reversing the list and hammering it down to single bits is trivial after

Structure is _nothing_ if it is all you got. Skeletons _spook_ people if
they try to walk around on their own. I really wonder why XML does not.
    -- Erik Naggum
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070602/10261bbe/attachment.bin

More information about the Haskell-Cafe mailing list