From f6507f70bc6b80fb7286c11a2e508259aad4315c Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 9 Jun 2015 20:58:55 +0100 Subject: [PATCH] Fix negative zero in currency display. --- src/localisation/localisation.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/localisation/localisation.c b/src/localisation/localisation.c index 182aefedc0..1facbdcee3 100644 --- a/src/localisation/localisation.c +++ b/src/localisation/localisation.c @@ -299,6 +299,10 @@ void format_currency(char **dest, long long value) int rate = currencySpec->rate; value *= rate; + // Divide by 100 to get rid of the pennies + // Do this before anything else to prevent negative zero. + value /= 100; + // Negative sign if (value < 0) { *(*dest)++ = '-'; @@ -314,8 +318,7 @@ void format_currency(char **dest, long long value) *dest += strlen(*dest); } - // Divide by 100 to get rid of the pennies - format_comma_separated_integer(dest, value / 100); + format_comma_separated_integer(dest, value); // Currency symbol suffix if (currencySpec->affix == CURRENCY_SUFFIX) {