Remove extraneous zeros from the standard formatting.

This commit is contained in:
speedplane 2016-05-03 15:17:19 -04:00
parent fcd0ac0192
commit 6e9d021d43
1 changed files with 6 additions and 2 deletions

View File

@ -234,8 +234,12 @@ class FloatObject(decimal.Decimal, PdfObject):
if self == self.to_integral():
return str(self.quantize(decimal.Decimal(1)))
else:
# XXX: this adds useless extraneous zeros.
return "%.5f" % self
# Standard formatting adds useless extraneous zeros.
o = "%.5f" % self
# Remove the zeros.
while o and o[-1] == '0':
o = o[:-1]
return o
def as_numeric(self):
return float(b_(repr(self)))