diff babel/numbers.py @ 576:e77dd06c40ef trunk

fix formatting of fraction in format_decimal() if the input value is a float with more than 7 significant digits (#183)
author fschwarz
date Sat, 28 Jul 2012 22:26:02 +0000
parents 39ff5164e8ea
children ea413a4d754b
line wrap: on
line diff
--- a/babel/numbers.py
+++ b/babel/numbers.py
@@ -478,6 +478,8 @@
         return '<%s %r>' % (type(self).__name__, self.pattern)
 
     def apply(self, value, locale, currency=None):
+        if isinstance(value, float):
+            value = Decimal(str(value))
         value *= self.scale
         is_negative = int(value < 0)
         if self.exp_prec: # Scientific notation
Copyright (C) 2012-2017 Edgewall Software