
23 Nov
2009
23 Nov
'09
9:31 a.m.
Hi all, I am trying to retrieve the decimal portion of a Double. My code is: getDecimal x = x - floor(x) I would expect the following: Main> getDecimal 1.23 0.23 :: [Double] but instead, I get: Main> getDecimal 1.23 ERROR - Unresolved overloading *** Type : (RealFrac a, Integral a) => a *** Expression : getDecimal 1.23 I have tried adding "getDecimal :: Double -> Double" but it only causes the following message to appear: ERROR file:C:\Documents and Settings\User\file.hs:60 - Instance of Integral Double required for definition of getDecimal How should I define my function so that it'll work? Thanks! Regards, Dom