| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Gini.Math.Amount.Internal
Contents
Synopsis
- data Amount
- type AmountScale = 30
- amountScale :: Int
- plusAmounts :: MonadThrow m => Amount -> Amount -> m Amount
- minusAmounts :: MonadThrow m => Amount -> Amount -> m Amount
- timesAmount :: MonadThrow m => Amount -> Integer -> m Amount
- quotRemAmount :: MonadThrow m => Amount -> Integer -> m (Amount, Amount)
- zeroAmount :: Amount
- oneAmount :: Amount
- amountToRational :: Amount -> Rational
- amountToFixed :: Amount -> Fixed FixedAmount
- data FixedAmount
Documentation
Instances
type AmountScale = 30 #
amountScale :: Int #
Value level scaling.
plusAmounts :: MonadThrow m => Amount -> Amount -> m Amount #
Sum two amounts together while checking that the result is valid.
minusAmounts :: MonadThrow m => Amount -> Amount -> m Amount #
Sum two amounts while checking that the result is valid.
timesAmount :: MonadThrow m => Amount -> Integer -> m Amount #
Multiply an amount by an Integer.
>>>pia <- 3.141592653589793238462643 :: IO Amount>>>pia `timesAmount` 1031.415926535897932384626430>>>pia `timesAmount` 100000314159.265358979323846264300000>>>pia `timesAmount` 10000000000*** Exception: arithmetic overflow
quotRemAmount :: MonadThrow m => Amount -> Integer -> m (Amount, Amount) #
Divide the amount and keep the remainder.
>>>pia <- 3.141592653589793238462643 :: IO Amount>>>pia `quotRemAmount` 1000000(0.000003141592653589793238,0.000000000000000000462643)>>>pia `quotRemAmount` (-7) :: Either SomeException (Amount, Amount)Left arithmetic underflow>>>pia `quotRemAmount` 0 :: Either SomeException (Amount, Amount)Left divide by zero
zeroAmount :: Amount #
Just a convenience constructor for an amount with value 0
Conversion
amountToRational :: Amount -> Rational #
amountToFixed :: Amount -> Fixed FixedAmount #
data FixedAmount #
Instances
| HasResolution FixedAmount # | |
Defined in Gini.Math.Amount.Internal Methods resolution :: p FixedAmount -> Integer # | |
