27 Nov
2007
27 Nov
'07
9:54 p.m.
Actually, IEEE numbers are designed in such a way, that if you interpret their bits as integer number, then 'succ' leads you to the next larger representable number. Thus you only have to cast from Float or Double to Int32 or Int64 respectively, call enumFromTo, then cast back to Float or Double, respectively. :-]
How do you cast from Float to Int32(or Word32), and back again? I couldn't find an appropriate function. Only thing I can see is going through the Storable interface, but that seems cumbersome and I imagine slow. Also, a related question: How do you convert from Float -> Double, and the reverse? Only thing I could find is (fromRational . toRational) which I also imagine to be slow, and I also wonder about accuracy. Thanks, Bit