License | MIT |
---|---|
Maintainer | douglas.mcclean@gmail.com |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions |
|
This type is sufficient to exactly express the closure of Q ∪ {π} under multiplication and division.
As a result it is useful for representing conversion factors
between physical units. Approximate values are included both to close the remainder
of the arithmetic operations in the Num
typeclass and to encode conversion
factors defined experimentally.
- data ExactPi
- = Exact Integer Rational
- | Approximate (forall a. Floating a => a)
- approximateValue :: Floating a => ExactPi -> a
- isZero :: ExactPi -> Bool
- isExactZero :: ExactPi -> Bool
- isExactOne :: ExactPi -> Bool
- isExactInteger :: ExactPi -> Bool
- toExactInteger :: ExactPi -> Maybe Integer
- isExactRational :: ExactPi -> Bool
- toExactRational :: ExactPi -> Maybe Rational
Documentation
Represents an exact or approximate real value. The exactly representable values are rational multiples of an integer power of pi.
approximateValue :: Floating a => ExactPi -> a Source
isZero :: ExactPi -> Bool Source
Identifies whether an ExactPi
is an exact or approximate representation of zero.
isExactZero :: ExactPi -> Bool Source
Identifies whether an ExactPi
is an exact representation of zero.
isExactOne :: ExactPi -> Bool Source
Identifies whether an ExactPi
is an exact representation of one.
isExactInteger :: ExactPi -> Bool Source
Identifies whether an ExactPi
is an exact representation of an integer.
toExactInteger :: ExactPi -> Maybe Integer Source
isExactRational :: ExactPi -> Bool Source
Identifies whether an ExactPi
is an exact representation of a rational.