Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation improvements for rounding methods #35431

Merged
merged 4 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sage/rings/real_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ cdef class RealBall(RingElement):

EXAMPLES:

It is possible to create balls whose midpoint is more precise that
It is possible to create balls whose midpoint is more precise than
their parent's nominal precision (see :mod:`~sage.rings.real_arb` for
more information)::

Expand Down
9 changes: 7 additions & 2 deletions src/sage/rings/real_double.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1521,15 +1521,20 @@ cdef class RealDoubleElement(FieldElement):

def round(self):
"""
Given real number `x`, rounds up if fractional part is greater than
`0.5`, rounds down if fractional part is less than `0.5`.
Rounds ``self`` to the nearest integer. Uses the convention of rounding
half to even (i.e. if the fractional part of ``self`` is `0.5`, then it
is rounded to the nearest even integer).
marizee marked this conversation as resolved.
Show resolved Hide resolved

EXAMPLES::

sage: RDF(0.49).round()
0
sage: a=RDF(0.51).round(); a
1
sage: RDF(0.5).round()
0
sage: RDF(1.5).round()
2
"""
return Integer(round(self._value))

Expand Down
6 changes: 4 additions & 2 deletions src/sage/rings/real_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2990,8 +2990,10 @@ cdef class RealNumber(sage.structure.element.RingElement):

def round(self):
"""
Rounds ``self`` to the nearest integer. The rounding mode of the
parent field has no effect on this function.
Rounds ``self`` to the nearest representable integer, rounding halfway
cases away from zero.
Note : the rounding mode of the parent field has no effect on this
function.
marizee marked this conversation as resolved.
Show resolved Hide resolved

EXAMPLES::

Expand Down