
12 Jan
2008
12 Jan
'08
7:08 p.m.
Is there a fast and reliable way to compute the fraction of a floating point number? I can implement fraction x = snd (properFraction x :: (Int, Double)) or fraction x = x - fromIntegral (truncate x :: Int) (actually I need 'floor' not 'truncate' but this is another issue) but these need considerably more time than fraction x = x - GHC.Float.int2Double (GHC.Float.double2Int x) Is there a fast 'fraction' built-in function? Or do I have to use FFI to modf ?