[pypy-commit] pypy py3k: py3 floats round half even
pjenvey
noreply at buildbot.pypy.org
Sat Dec 15 02:25:48 CET 2012
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r59429:6719c0d71e7c
Date: 2012-12-14 17:20 -0800
http://bitbucket.org/pypy/pypy/changeset/6719c0d71e7c/
Log: py3 floats round half even
diff --git a/pypy/objspace/std/floattype.py b/pypy/objspace/std/floattype.py
--- a/pypy/objspace/std/floattype.py
+++ b/pypy/objspace/std/floattype.py
@@ -304,7 +304,7 @@
return space.wrap(0.0 * x)
# finite x, and ndigits is not unreasonably large
- z = rfloat.round_double(x, ndigits)
+ z = rfloat.round_double(x, ndigits, half_even=True)
if rfloat.isinf(z):
raise OperationError(space.w_OverflowError,
space.wrap("overflow occurred during round"))
diff --git a/pypy/objspace/std/test/test_floatobject.py b/pypy/objspace/std/test/test_floatobject.py
--- a/pypy/objspace/std/test/test_floatobject.py
+++ b/pypy/objspace/std/test/test_floatobject.py
@@ -188,6 +188,7 @@
assert round(123.456, -700) == 0.0
assert round(123.456, -2**100) == 0.0
assert math.copysign(1., round(-123.456, -700)) == -1.
+ assert round(2.5, 0) == 2.0
def test_special_float_method(self):
class a(object):
More information about the pypy-commit
mailing list