[Python-checkins] r71715 - in python/trunk: Lib/test/test_builtin.py Misc/NEWS Python/bltinmodule.c
mark.dickinson
python-checkins at python.org
Sat Apr 18 16:59:42 CEST 2009
Author: mark.dickinson
Date: Sat Apr 18 16:59:42 2009
New Revision: 71715
Log:
Issue #1869: Fix a couple of minor round() issues.
Modified:
python/trunk/Lib/test/test_builtin.py
python/trunk/Misc/NEWS
python/trunk/Python/bltinmodule.c
Modified: python/trunk/Lib/test/test_builtin.py
==============================================================================
--- python/trunk/Lib/test/test_builtin.py (original)
+++ python/trunk/Lib/test/test_builtin.py Sat Apr 18 16:59:42 2009
@@ -1224,6 +1224,9 @@
self.assertEqual(round(-5.5), -6)
self.assertEqual(round(-6.5), -7)
+ # Issue #1869: integral floats should remain unchanged
+ self.assertEqual(round(5e15+1), 5e15+1)
+
# Check behavior on ints
self.assertEqual(round(0), 0)
self.assertEqual(round(8), 8)
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sat Apr 18 16:59:42 2009
@@ -12,6 +12,9 @@
Core and Builtins
-----------------
+- Issue #1869: fix a couple of minor round() issues. round(5e15+1)
+ was giving 5e15+2; round(-0.0) was losing the sign of the zero.
+
- Issue #5759: float() didn't call __float__ on str subclasses.
- Issue #5704: the "-3" command-line option now implies "-t".
Modified: python/trunk/Python/bltinmodule.c
==============================================================================
--- python/trunk/Python/bltinmodule.c (original)
+++ python/trunk/Python/bltinmodule.c Sat Apr 18 16:59:42 2009
@@ -2081,10 +2081,7 @@
number /= f;
else
number *= f;
- if (number >= 0.0)
- number = floor(number + 0.5);
- else
- number = ceil(number - 0.5);
+ number = round(number);
if (ndigits < 0)
number *= f;
else
More information about the Python-checkins
mailing list