From 4a7668adca60a75fb41c87781caa5672871f65cf Mon Sep 17 00:00:00 2001 From: Nick Coghlan Date: Sat, 8 Feb 2014 23:55:14 +1000 Subject: Close #20536: correctly handle Decimal exponents in statistics --- Lib/statistics.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Lib/statistics.py') 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) -- cgit v1.2.1