Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- roundHalfUp :: (RealFrac a, Integral b) => a -> b
- roundHalfUp x | diff == 0.5 = ceiling x
- | otherwise = round x
- where diff = x - fromIntegral (floor x)
- roundHalfAway :: (RealFrac a, Integral b) => a -> b
- roundHalfAway x | x >= 0 = roundHalfUp x
- | otherwise = negate $ roundHalfUp $ abs x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement