-
-
Notifications
You must be signed in to change notification settings - Fork 657
Closed
Closed
Copy link
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues for a bug report that matches the one I want to file, without success.
Problem Description
The documentation for RationalField's round
method says
Return the nearest integer to ``self``, rounding away from 0 by
default, for consistency with the builtin Python round.
Yet the builtin Python round
currently (since Python3 I think) rounds to nearest, with halfway case rounding to even. The first example in the documentation is (9/2).round()
which yields 5
, and consequently in Sage round(9/2)
yields 5
as well; whereas in Python the same round(9/2)
yields 4
.
Proposed Solution
A simple solution may be to change the default to even
, which is the current Python convention and is already implemented in this method round
for rational field.
Alternatives Considered
Or, seemingly less ideal: one could keep the current behaviour and modify the documentation to highlight that this diverges from Python's builtin behaviour.
Additional Information
No response