Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

# RealFrac

class (Real a, Fractional a) => RealFrac a where #

Extracting components of fractions.

properFraction :: Integral b => a -> (b, a) #

The function `properFraction`

takes a real fractional number `x`

and returns a pair `(n,f)`

such that `x = n+f`

, and:

`n`

is an integral number with the same sign as`x`

; and`f`

is a fraction with the same type and sign as`x`

, and with absolute value less than`1`

.

The default definitions of the `ceiling`

, `floor`

, `truncate`

and `round`

functions are in terms of `properFraction`

.

truncate :: Integral b => a -> b #

returns the integer nearest `truncate`

x`x`

between zero and `x`

round :: Integral b => a -> b #

returns the nearest integer to `round`

x`x`

;
the even integer if `x`

is equidistant between two integers

ceiling :: Integral b => a -> b #

returns the least integer not less than `ceiling`

x`x`

floor :: Integral b => a -> b #

returns the greatest integer not greater than `floor`

x`x`