Hi! According to IEEE 754, the default rounding mode for floating-point operations is "round half to even". However, if one calls "round" on elements of RR, the rounding apparently is "round half away from zero if the total number of digits in the result is odd and towards zero if the total number of digits of the result is even":
sage: round(3.5, ndigits=0) 4 sage: round(3.55, ndigits=1) 3.5 sage: round(3.555, ndigits=2) 3.56 sage: round(-3.5, ndigits=0) -4 sage: round(-3.55, ndigits=1) -3.5 sage: round(-3.555, ndigits=2) -3.56 sage: round(-13.555, ndigits=2) -13.55 sage: round(13.555, ndigits=2) 13.55 sage: builtins.round(13.555) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-29-9b82fece61b0> in <module>() ----> 1 builtins.round(RealNumber('13.555')) TypeError: type sage.rings.real_mpfr.RealLiteral doesn't define __round__ method This gives rise to loads of questions: 1. Is the rule that I formulated really what is used? 2. Is it documented somewhere? It is neither documented in the round() function nor in the .round() method of sage.rings.real_mpfr.RealLiteral. 3. Is there some "official" standard (similar to IEEE 754) supporting Sage's rounding? 4. Shouldn't the rounding be defined in a .__round__() method rather than in a .round() method? 5. Is it possible to explicitly request "half to even" rounding? Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/r67qsf%24hha%241%40ciao.gmane.io.