lib: Improve documentation for amountRoundedQuantity, fix a typo.

This commit is contained in:
Stephen Morgan 2020-08-21 11:51:50 +10:00
parent f6fa76bba7
commit 7182fa4746
2 changed files with 2 additions and 2 deletions

View File

@ -261,7 +261,7 @@ multiplyAmountAndPrice n a@Amount{aquantity=q,aprice=p} = a{aquantity=q*n, apric
isNegativeAmount :: Amount -> Bool isNegativeAmount :: Amount -> Bool
isNegativeAmount Amount{aquantity=q} = q < 0 isNegativeAmount Amount{aquantity=q} = q < 0
-- | Round an Amount to its specified display precision. If that is -- | Round an Amount's Quantity to its specified display precision. If that is
-- NaturalPrecision, this does nothing. -- NaturalPrecision, this does nothing.
amountRoundedQuantity :: Amount -> Quantity amountRoundedQuantity :: Amount -> Quantity
amountRoundedQuantity Amount{aquantity=q, astyle=AmountStyle{asprecision=p}} = case p of amountRoundedQuantity Amount{aquantity=q, astyle=AmountStyle{asprecision=p}} = case p of

View File

@ -855,7 +855,7 @@ fromRawNumber raw mExp = do
toQuantity e preDecimalGrp postDecimalGrp toQuantity e preDecimalGrp postDecimalGrp
| precision < 0 = Right (Decimal 0 (digitGrpNum * 10^(-precision)), 0) | precision < 0 = Right (Decimal 0 (digitGrpNum * 10^(-precision)), 0)
| precision < 256 = Right (Decimal precision8 digitGrpNum, precision8) | precision < 256 = Right (Decimal precision8 digitGrpNum, precision8)
| otherwise = Left "invalid number: numbers with more than 255 decimal digits are now allowed at this time" | otherwise = Left "invalid number: numbers with more than 255 decimal digits are not allowed at this time"
where where
digitGrpNum = digitGroupNumber $ preDecimalGrp <> postDecimalGrp digitGrpNum = digitGroupNumber $ preDecimalGrp <> postDecimalGrp
precision = toInteger (digitGroupLength postDecimalGrp) - e precision = toInteger (digitGroupLength postDecimalGrp) - e