Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/mathlib.py
diff options
context:
space:
mode:
authorReinier Heeres <reinier@heeres.eu>2010-07-27 11:15:55 (GMT)
committer Reinier Heeres <reinier@heeres.eu>2010-07-27 11:15:55 (GMT)
commitcf301b50836dc05224b858e703fa4f91170b3720 (patch)
treef39172ae686f1c75a58d44726af0e14c934317e0 /mathlib.py
parent33be8fac1e1f1c4d653c74ba8ed9c3f2a03d4872 (diff)
Fix dropping of zeros on integers
Diffstat (limited to 'mathlib.py')
-rw-r--r--mathlib.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/mathlib.py b/mathlib.py
index 55f7807..9f7a301 100644
--- a/mathlib.py
+++ b/mathlib.py
@@ -137,7 +137,7 @@ class MathLib:
return (digits, exp)
i = len(digits) - 1
- while digits[i] == 0 and i > 0:
+ while digits[i] == 0 and i > 0 and exp > 0:
i -= 1
exp -= 1
@@ -260,7 +260,7 @@ if __name__ == "__main__":
print 'is_int(%.18e): %s' % (val, ml.is_int(val))
val = ml.d(0.99999999999999878)**2
print 'is_int(%s): %s' % (val, ml.is_int(val))
- vals = ('0.1230', '12.34', '0.0123')
+ vals = ('0.1230', '12.34', '0.0123', '1230', '123.0', '1.230e17')
for valstr in vals:
val = ml.d(valstr)
print 'Formatted value: %s (from %s)' % (ml.format_number(val), valstr)