summaryrefslogtreecommitdiff
path: root/Lib/statistics.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-02-08 23:55:14 +1000
committerNick Coghlan <ncoghlan@gmail.com>2014-02-08 23:55:14 +1000
commit4a7668adca60a75fb41c87781caa5672871f65cf (patch)
treeb449a081b2ac4cda0ef118e03a0ffad48cb52374 /Lib/statistics.py
parentf45e3e34b252bf878827ff1c288e1ea31a499054 (diff)
downloadcpython-git-4a7668adca60a75fb41c87781caa5672871f65cf.tar.gz
Close #20536: correctly handle Decimal exponents in statistics
Diffstat (limited to 'Lib/statistics.py')
-rw-r--r--Lib/statistics.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/statistics.py b/Lib/statistics.py
index e1dfbd4931..25a26d4aa7 100644
--- a/Lib/statistics.py
+++ b/Lib/statistics.py
@@ -243,9 +243,13 @@ def _decimal_to_ratio(d):
num = 0
for digit in digits:
num = num*10 + digit
+ if exp < 0:
+ den = 10**-exp
+ else:
+ num *= 10**exp
+ den = 1
if sign:
num = -num
- den = 10**-exp
return (num, den)