| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Double.Shaman
Synopsis
- data Shaman
- significativeBits :: Shaman -> Double
- significativeDigits :: Shaman -> Double
- data SDouble (n :: Nat)
Documentation
Double-precision floating point numbers with error-bounds.
Some digits can be represented exactly and have essentially an infinitely number of significant digits:
>>>significativeDigits 1Infinity
Some fractional numbers can also be represented exactly:
>>>significativeDigits 0.5Infinity
Other numbers are merely approximations:
>>>significativeDigits 0.116.255619765854984
Pi is an irrational number so we can't represent it with infinite precision:
>>>significativeDigits pi15.849679651557175
sin pi should theoretically be zero but we cannot do better than saying it is near zero:
>>>sin pi1.2246467991473532e-16
The error margins are greater than value itself so we have no significant digits:
>>>significativeDigits (sin pi)0.0
Since 'near zero' is not zero, the following fails when using Doubles:
>>>sin pi == (0 :: Double)False
Equality testing for Shaman numbers tests whether the two intervals overlap:
>>>sin pi == (0 :: Shaman)True
Instances
| Eq Shaman Source # | |
| Floating Shaman Source # | |
| Fractional Shaman Source # | |
| Num Shaman Source # | |
| Ord Shaman Source # | |
| Read Shaman Source # | |
| Real Shaman Source # | |
Defined in Data.Double.Shaman Methods toRational :: Shaman -> Rational # | |
| RealFloat Shaman Source # | |
Defined in Data.Double.Shaman Methods floatRadix :: Shaman -> Integer # floatDigits :: Shaman -> Int # floatRange :: Shaman -> (Int, Int) # decodeFloat :: Shaman -> (Integer, Int) # encodeFloat :: Integer -> Int -> Shaman # significand :: Shaman -> Shaman # scaleFloat :: Int -> Shaman -> Shaman # isInfinite :: Shaman -> Bool # isDenormalized :: Shaman -> Bool # isNegativeZero :: Shaman -> Bool # | |
| RealFrac Shaman Source # | |
| Show Shaman Source # | |
significativeBits :: Shaman -> Double Source #
Number of significant bits (base 2).
significativeDigits :: Shaman -> Double Source #
Number of significant digits (base 10).
data SDouble (n :: Nat) Source #
Double-precision floating point numbers that throw exceptions if the accumulated errors grow large enough to cause unstable branching.
If SDouble n works without throwing any exceptions, it'll be safe to
use DoubleRelAbs n 0 instead for a sizable performance boost.
>>>sin pi == (0 :: SDouble 0)*** Exception: Insufficient precision. ...
SDouble 0 failed so DoubleRelAbs 0 0 will lead to an unstable branch. In
other words, it'll return False when it should have returned True:
>>>sin pi == (0 :: DoubleRelAbs 0 0)False
Comparing to within 1 ULP stabalizes the branch:
>>>sin pi == (0 :: SDouble 1)True
>>>sin pi == (0 :: DoubleRelAbs 1 0)True