Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
HGeometry.Number.Real.Rational
Description
Synopsis
- newtype RealNumber (p :: Nat) = RealNumber Rational
- data AsFixed p
- asFixed :: KnownNat p => RealNumber p -> AsFixed (NatPrec p)
- toFixed :: KnownNat p => RealNumber p -> Fixed (NatPrec p)
- fromFixed :: KnownNat p => Fixed (NatPrec p) -> RealNumber p
- type Nat = Natural
Documentation
newtype RealNumber (p :: Nat) Source #
Real Numbers represented using Rational numbers. The number type itself is exact in the sense that we can represent any rational number.
The parameter, a natural number, represents the precision (in number of decimals behind the period) with which we display the numbers when printing them (using Show).
If the number cannot be displayed exactly a ~
is printed after
the number.
Constructors
RealNumber Rational |
Instances
Converting to and from RealNumber's
Fixed-precision representation of a RealNumber
. If there's insufficient
precision to accurately represent the RealNumber
then the Lossy
constructor
will be used.
asFixed :: KnownNat p => RealNumber p -> AsFixed (NatPrec p) Source #
Cast RealNumber
to a fixed-precision number. Data-loss caused by insufficient
precision will be marked by the Lossy
constructor.
toFixed :: KnownNat p => RealNumber p -> Fixed (NatPrec p) Source #
Cast RealNumber
to a fixed-precision number. Data is silently lost if there's
insufficient precision.
fromFixed :: KnownNat p => Fixed (NatPrec p) -> RealNumber p Source #
Cast a fixed-precision number to a RealNumber
.