definition:
|
class (Real a, Fractional a) => RealFrac a where
properFraction :: Integral b => a -> (b, a)
truncate :: Integral b => a -> b
round :: Integral b => a -> b
ceiling :: Integral b => a -> b
floor :: Integral b => a -> b
truncate x = m
where (m, _) = properFraction x
round x = let (n, r) = properFraction x
m = if r < 0 then n - 1 else n + 1
in case compare (signum (abs r - 0.5)) 0 of
LT -> n
EQ -> if even n then n else m
GT -> m
ceiling x = if r > 0 then n + 1 else n
where (n, r) = properFraction x
floor x = if r < 0 then n - 1 else n
where (n, r) = properFraction x
|
methods:
|
["properFraction :: Integral b => a -> (b, a)","truncate 1 :: Integral b => a -> b","round 1 :: Integral b => a -> b","ceiling 1 :: Integral b => a -> b","floor 1 :: Integral b => a -> b"]
|