[Haskell-cafe] Convert Double to Data.Fixed

Eugene Kirpichov ekirpichov at gmail.com
Mon Dec 26 16:55:38 CET 2011

Hi cafe,

How do I most efficiently convert a Double to a Data.Fixed?

I'm asking because I want to convert fractional seconds to the seconds
field of Data.Time.TimeOfDay, which is Pico = Data.Fixed.Fixed E12.

For now the fastest thing I came up with was fromIntegral (round
(sec*1000000)) / fromIntegral 1000000, but this frankly sucks and is rather
slow, there must be a better way.

Eugene Kirpichov
Principal Engineer, Mirantis Inc. http://www.mirantis.com/
Editor, http://fprog.ru/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111226/e099a69d/attachment.htm>

More information about the Haskell-Cafe mailing list