From 4120a874d8361079bbb039dc708bcd781ea3d4b3 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 25 May 2010 22:17:54 +0000 Subject: [PATCH] test zero to 8 instead of 10 places, workaround for rounding error affecting a real-world transaction --- hledger-lib/Hledger/Data/Amount.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hledger-lib/Hledger/Data/Amount.hs b/hledger-lib/Hledger/Data/Amount.hs index 8c4fadcbb..22c12a57c 100644 --- a/hledger-lib/Hledger/Data/Amount.hs +++ b/hledger-lib/Hledger/Data/Amount.hs @@ -150,7 +150,8 @@ isZeroAmount = null . filter (`elem` "123456789") . showAmountWithoutPrice -- | Is this amount "really" zero, regardless of the display precision ? -- Since we are using floating point, for now just test to some high precision. isReallyZeroAmount :: Amount -> Bool -isReallyZeroAmount = null . filter (`elem` "123456789") . printf "%.10f" . quantity +isReallyZeroAmount = null . filter (`elem` "123456789") . printf ("%."++show zeroprecision++"f") . quantity + where zeroprecision = 8 -- | Access a mixed amount's components. amounts :: MixedAmount -> [Amount]