Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Amounts of BTC
- newtype Amount = Amount {}
- btc :: Double -> Amount
- mbtc :: Double -> Amount
- ubtc :: Double -> Amount
- satoshi :: Int -> Amount
- amountMultiplier :: Num a => a
- amountExponent :: Int
- integerAmount :: Amount -> Integer
- doubleAmount :: Amount -> Double
- amountFromDouble :: Double -> Amount
- showAmount :: Amount -> String
- parseAmount :: String -> Maybe Amount
Documentation
A (nonnegative) amount of bitcoins.
Note: the Show/Read instances look like
newtype Amount = BTC Double
eg. BTC 1.3
However, the internal representation is different.
human-friendly definitions of amounts
constants
amountMultiplier :: Num a => a Source #
10^amountExponent == 10^8
amountExponent :: Int Source #
The exponent is 8, as 10^(-8)
is the smallest unit.
conversion
integerAmount :: Amount -> Integer Source #
The amount measured in smallest units (satoshis)
amountFromDouble :: Double -> Amount Source #
Convert whole BTCs to an Amount. Rounding to whole satoshis.
showAmount :: Amount -> String Source #
Shows an amount in BTCs using the minimum necessary digits