data-extra-2.5.3: Extra utilities for working on Data.* types.

Safe HaskellSafe-Inferred

Data.Number.Extra

Description

Extra functions for numbers.

Synopsis

Documentation

towardZero :: (Integral b, RealFrac a) => a -> bSource

Round toward zero (truncate).

towardInf :: (Integral b, RealFrac a) => a -> bSource

Round upwards (ceiling).

towardNegInf :: (Integral b, RealFrac a) => a -> bSource

Round backwards (floor).

awayFromZero :: (Integral b, RealFrac a) => a -> bSource

Round away from zero (ceiling if positive, floor otherwise).

nearestTowardZero :: (Integral b, RealFrac a) => a -> bSource

Round torwards zero (if half go towards zero, otherwise up to 1).

nearestTowardInf :: (Integral b, RealFrac a) => a -> bSource

Same as nearestTowardZero but to infinity instead of zero.

nearestTowardNegInf :: (Integral b, RealFrac a) => a -> bSource

Same as nearestTowardZero but towards negative instead of zero.

nearestAwayFromZero :: (Integral b, RealFrac a) => a -> bSource

Same as nearestTowardZero but rounds away from zero (by positive or negative).

nearestBanker :: (Integral b, RealFrac a) => a -> bSource

Round up (round).

fi :: (Integral a, Num b) => a -> bSource

Short-hand for fromIntegral.

isHalf :: RealFrac a => a -> BoolSource

Is a number rounded down 0.5?

int :: (Integral a, Num b) => a -> bSource

Short-hand for fromIntegral. Deprecated in favour of the more popular fi.