This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author priska
Recipients priska
Date 2015-06-07.10:58:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1433674721.13.0.236886844827.issue24403@psf.upfronthosting.co.za>
In-reply-to
Content
The behavior of the round() function has changed between Python 2.x and Python3.x. 

From the release notes of Python 3.0: "The round() function rounding strategy and return type have changed. Exact halfway cases are now rounded to the nearest even result instead of away from zero. (For example, round(2.5) now returns 2 rather than 3.) round(x[, n]) now delegates to x.__round__([n]) instead of always returning a float. It generally returns an integer when called with a single argument and a value of the same type as x when called with two arguments."

2to3 conversion does not take this into account and thereby changes code behavior.

Suggested translations:

round(n) -> float(math.floor(n + math.copysign(0.5, n)))

or 

round(n) -> float(math.trunc(n + math.copysign(0.5, n)))
History
Date User Action Args
2015-06-07 10:58:41priskasetrecipients: + priska
2015-06-07 10:58:41priskasetmessageid: <1433674721.13.0.236886844827.issue24403@psf.upfronthosting.co.za>
2015-06-07 10:58:41priskalinkissue24403 messages
2015-06-07 10:58:40priskacreate