;lib: clarify docs for setFullPrecision, setNaturalPrecision
This commit is contained in:
parent
a081404bd7
commit
279e9624ed
@ -277,17 +277,17 @@ isReallyZeroAmount Amount{aquantity=q} = q == 0
|
|||||||
showAmountWithPrecision :: Int -> Amount -> String
|
showAmountWithPrecision :: Int -> Amount -> String
|
||||||
showAmountWithPrecision p = showAmount . setAmountPrecision p
|
showAmountWithPrecision p = showAmount . setAmountPrecision p
|
||||||
|
|
||||||
-- | Set an amount's display precision.
|
|
||||||
setAmountPrecision :: Int -> Amount -> Amount
|
|
||||||
setAmountPrecision p a@Amount{astyle=s} = a{astyle=s{asprecision=p}}
|
|
||||||
|
|
||||||
-- | Set an amount's display precision, flipped.
|
-- | Set an amount's display precision, flipped.
|
||||||
withPrecision :: Amount -> Int -> Amount
|
withPrecision :: Amount -> Int -> Amount
|
||||||
withPrecision = flip setAmountPrecision
|
withPrecision = flip setAmountPrecision
|
||||||
|
|
||||||
-- | Increase an amount's display precision, if necessary, enough so
|
-- | Set an amount's display precision.
|
||||||
-- that it will be shown exactly, with all significant decimal places
|
setAmountPrecision :: Int -> Amount -> Amount
|
||||||
-- (excluding trailing zeros).
|
setAmountPrecision p a@Amount{astyle=s} = a{astyle=s{asprecision=p}}
|
||||||
|
|
||||||
|
-- | Increase an amount's display precision, if needed, to enough
|
||||||
|
-- decimal places to show it exactly (showing all significant decimal
|
||||||
|
-- digits, excluding trailing zeros).
|
||||||
setFullPrecision :: Amount -> Amount
|
setFullPrecision :: Amount -> Amount
|
||||||
setFullPrecision a = setAmountPrecision p a
|
setFullPrecision a = setAmountPrecision p a
|
||||||
where
|
where
|
||||||
@ -295,16 +295,18 @@ setFullPrecision a = setAmountPrecision p a
|
|||||||
displayprecision = asprecision $ astyle a
|
displayprecision = asprecision $ astyle a
|
||||||
normalprecision = fromIntegral $ decimalPlaces $ normalizeDecimal $ aquantity a
|
normalprecision = fromIntegral $ decimalPlaces $ normalizeDecimal $ aquantity a
|
||||||
|
|
||||||
-- | Set an amount's display precision to just enough so that it will
|
-- | Set an amount's display precision to just enough decimal places
|
||||||
-- be shown exactly, with all significant decimal places.
|
-- to show it exactly (possibly less than the number specified by
|
||||||
|
-- the amount's display style).
|
||||||
setNaturalPrecision :: Amount -> Amount
|
setNaturalPrecision :: Amount -> Amount
|
||||||
setNaturalPrecision a = setAmountPrecision normalprecision a
|
setNaturalPrecision a = setAmountPrecision normalprecision a
|
||||||
where
|
where
|
||||||
normalprecision = fromIntegral $ decimalPlaces $ normalizeDecimal $ aquantity a
|
normalprecision = fromIntegral $ decimalPlaces $ normalizeDecimal $ aquantity a
|
||||||
|
|
||||||
-- | Set an amount's display precision to just enough so that all
|
-- | Set an amount's display precision to just enough decimal places
|
||||||
-- significant decimal digits will be shown, but not more than the
|
-- to show it exactly (possibly less than the number specified by the
|
||||||
-- given maximum number of decimal digits.
|
-- amount's display style), but not more than the given maximum number
|
||||||
|
-- of decimal digits.
|
||||||
setNaturalPrecisionUpTo :: Int -> Amount -> Amount
|
setNaturalPrecisionUpTo :: Int -> Amount -> Amount
|
||||||
setNaturalPrecisionUpTo n a = setAmountPrecision (min n normalprecision) a
|
setNaturalPrecisionUpTo n a = setAmountPrecision (min n normalprecision) a
|
||||||
where
|
where
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user