Mercurial > babel > mirror
comparison 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 |
comparison
equal
deleted
inserted
replaced
575:8ce41e60f90d | 576:e77dd06c40ef |
---|---|
476 | 476 |
477 def __repr__(self): | 477 def __repr__(self): |
478 return '<%s %r>' % (type(self).__name__, self.pattern) | 478 return '<%s %r>' % (type(self).__name__, self.pattern) |
479 | 479 |
480 def apply(self, value, locale, currency=None): | 480 def apply(self, value, locale, currency=None): |
481 if isinstance(value, float): | |
482 value = Decimal(str(value)) | |
481 value *= self.scale | 483 value *= self.scale |
482 is_negative = int(value < 0) | 484 is_negative = int(value < 0) |
483 if self.exp_prec: # Scientific notation | 485 if self.exp_prec: # Scientific notation |
484 value = abs(value) | 486 value = abs(value) |
485 if value: | 487 if value: |