From 495dfa37a41a150d16d1fb89d414f52973424dcf Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 19 Mar 2020 14:24:57 -0700 Subject: [PATCH] ;journal: document banker's rounding behaviour --- hledger-lib/hledger_journal.m4.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/hledger-lib/hledger_journal.m4.md b/hledger-lib/hledger_journal.m4.md index 06d9bcda9..1ce6dd6eb 100644 --- a/hledger-lib/hledger_journal.m4.md +++ b/hledger-lib/hledger_journal.m4.md @@ -496,8 +496,17 @@ problems, use a commodity directive to fix the display style. In summary: amounts will be displayed much as they appear in your journal, with the max observed number of decimal places. If you want -to see fewer decimal places in reports, use a commodity directive to -override that. +to see fewer decimal places in reports, use a +[commodity directive](#declaring-commodities) +to override that. + +hledger uses [banker's rounding](https://en.wikipedia.org/wiki/Bankers_rounding): +it rounds to the nearest even number, eg 0.5 displayed with zero +decimal places is "0"). +(Note, prior to hledger 1.17.1 this could vary if hledger happened to +be built with an old version of Decimal (<0.5.1); since 1.17.1 it's +guaranteed.) + ## Transaction prices @@ -933,6 +942,11 @@ The quantity of the amount does not matter; only the format is significant. The number must include a decimal mark: either a period or a comma, followed by 0 or more decimal digits. +Note hledger normally uses +[banker's rounding](https://en.wikipedia.org/wiki/Bankers_rounding), +so 0.5 displayed with zero decimal digits is "0". +(More at [Amounts](#amounts).) + ### Default commodity The `D` directive sets a default commodity, to be used for amounts without a commodity symbol (ie, plain numbers).