| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
NumHask.Data.Rational
Contents
Description
Integral classes
Documentation
Constructors
| !a :% !a |
Instances
class ToRatio a where Source #
toRatio is equivalent to Real in base.
Instances
| ToRatio Double Source # | |
| ToRatio Float Source # | |
| ToRatio Int Source # | |
| ToRatio Int8 Source # | |
| ToRatio Int16 Source # | |
| ToRatio Int32 Source # | |
| ToRatio Int64 Source # | |
| ToRatio Integer Source # | |
| ToRatio Natural Source # | |
| ToRatio Rational Source # | |
| ToRatio Word Source # | |
| ToRatio Word8 Source # | |
| ToRatio Word16 Source # | |
| ToRatio Word32 Source # | |
| ToRatio Word64 Source # | |
| ToInteger a => ToRatio (Ratio a) Source # | |
| (ToRatio a, ExpField a) => ToRatio (LogField a) Source # | |
| ToRatio a => ToRatio (Wrapped a) Source # | |
class FromRatio a where Source #
Fractional in base splits into fromRatio and Field
$integral_functionality
reduce :: (Eq a, Subtractive a, Signed a, Integral a) => a -> a -> Ratio a Source #
reduce is a subsidiary function used only in this module.
It normalises a ratio by dividing both numerator and denominator by
their greatest common divisor.
gcd :: (Eq a, Signed a, Integral a) => a -> a -> a Source #
is the non-negative factor of both gcd x yx 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 44. = gcd 0 00.
(That is, the common divisor that is "greatest" in the divisibility
preordering.)
Note: Since for signed fixed-width integer types, ,
the result may be negative if one of the arguments is abs minBound < 0 (and
necessarily is if the other is minBound0 or ) for such types.minBound