From 23902ab7c5a687a59b80552e6f695867224cab23 Mon Sep 17 00:00:00 2001 From: CrazyMerlyn Date: Sun, 16 Sep 2018 21:24:35 +0530 Subject: [PATCH] [FIX] lang_FR: Fixed decimal handling in french currency Fixes #179 --- num2words/lang_FR.py | 5 +++-- tests/test_fr.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/num2words/lang_FR.py b/num2words/lang_FR.py index c5ff4b0..5eff2db 100644 --- a/num2words/lang_FR.py +++ b/num2words/lang_FR.py @@ -96,5 +96,6 @@ class Num2Word_FR(Num2Word_EU): hightxt = "euro/s" if old: hightxt = "franc/s" - return self.to_splitnum(val, hightxt=hightxt, lowtxt="centime/s", - divisor=1, jointxt="et", longval=longval) + cents = int(round(val*100)) + return self.to_splitnum(cents, hightxt=hightxt, lowtxt="centime/s", + divisor=100, jointxt="et", longval=longval) diff --git a/tests/test_fr.py b/tests/test_fr.py index c9e25da..deeec22 100644 --- a/tests/test_fr.py +++ b/tests/test_fr.py @@ -122,6 +122,7 @@ TEST_CASES_TO_CURRENCY = ( (12, 'douze euros'), (21, 'vingt et un euros'), (81.25, 'quatre-vingt-un euros et vingt-cinq centimes'), + (81.2, 'quatre-vingt-un euros et vingt centimes'), (100, 'cent euros'), ) @@ -132,6 +133,7 @@ TEST_CASES_TO_CURRENCY_OLD = ( (12, 'douze francs'), (21, 'vingt et un francs'), (81.25, 'quatre-vingt-un francs et vingt-cinq centimes'), + (81.2, 'quatre-vingt-un francs et vingt centimes'), (100, 'cent francs'), )