cafeteria-prelude-0.1.0.0: Prelude subsets—take only what you want!

Safe HaskellSafe-Inferred
LanguageHaskell2010

Prelude.Source.GHC.Real

Synopsis

Documentation

type Rational = Ratio Integer

Arbitrary-precision rational numbers, represented as a ratio of two Integer values. A rational number may be constructed using the % operator.

class (Num a, Ord a) => Real a where

Methods

toRational :: a -> Rational

the rational equivalent of its real argument with full precision

class (Real a, Enum a) => Integral a where

Integral numbers, supporting integer division.

Minimal complete definition: quotRem and toInteger

Minimal complete definition

quotRem, toInteger

Methods

quot :: a -> a -> a infixl 7

integer division truncated toward zero

rem :: a -> a -> a infixl 7

integer remainder, satisfying

(x `quot` y)*y + (x `rem` y) == x

div :: a -> a -> a infixl 7

integer division truncated toward negative infinity

mod :: a -> a -> a infixl 7

integer modulus, satisfying

(x `div` y)*y + (x `mod` y) == x

quotRem :: a -> a -> (a, a)

simultaneous quot and rem

divMod :: a -> a -> (a, a)

simultaneous div and mod

toInteger :: a -> Integer

conversion to Integer

class Num a => Fractional a where

Fractional numbers, supporting real division.

Minimal complete definition: fromRational and (recip or (/))

Minimal complete definition

fromRational, (recip | (/))

Methods

(/) :: a -> a -> a infixl 7

fractional division

recip :: a -> a

reciprocal fraction

fromRational :: Rational -> a

Conversion from a Rational (that is Ratio Integer). A floating literal stands for an application of fromRational to a value of type Rational, so such literals have type (Fractional a) => a.

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

Extracting components of fractions.

Minimal complete definition: properFraction

Minimal complete definition

properFraction

Methods

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

truncate x returns the integer nearest x between zero and x

round :: Integral b => a -> b

round x returns the nearest integer to x; the even integer if x is equidistant between two integers

ceiling :: Integral b => a -> b

ceiling x returns the least integer not less than x

floor :: Integral b => a -> b

floor x returns the greatest integer not greater than x

even :: Integral a => a -> Bool

odd :: Integral a => a -> Bool

gcd :: Integral a => a -> a -> a

gcd x y is the non-negative factor of both x and y of which every common factor of x and y is also a factor; for example gcd 4 2 = 2, gcd (-4) 6 = 2, gcd 0 4 = 4. gcd 0 0 = 0. (That is, the common divisor that is "greatest" in the divisibility preordering.)

Note: Since for signed fixed-width integer types, abs minBound < 0, the result may be negative if one of the arguments is minBound (and necessarily is if the other is 0 or minBound) for such types.

lcm :: Integral a => a -> a -> a

lcm x y is the smallest positive integer that both x and y divide.

(^) :: (Num a, Integral b) => a -> b -> a infixr 8

raise a number to a non-negative integral power

(^^) :: (Fractional a, Integral b) => a -> b -> a infixr 8

raise a number to an integral power

fromIntegral :: (Integral a, Num b) => a -> b

general coercion from integral types

realToFrac :: (Real a, Fractional b) => a -> b

general coercion to fractional types