Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. roundHalfUp :: (RealFrac a, Integral b) => a -> b
  2. roundHalfUp x | diff == 0.5 = ceiling x
  3.               | otherwise   = round x
  4.   where diff = x - fromIntegral (floor x)
  5.  
  6. roundHalfAway :: (RealFrac a, Integral b) => a -> b
  7. roundHalfAway x | x >= 0    = roundHalfUp x
  8.                 | otherwise = negate $ roundHalfUp $ abs x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement