Bugs item #1725899, was opened at 2007-05-25 22:52 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1725899&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Mark Dickinson (marketdickinson) Assigned to: Nobody/Anonymous (nobody) Summary: decimal sqrt method doesn't use round-half-even Initial Comment: According to version 1.66 of Cowlishaw's `General Decimal Arithmetic Specification' the square-root operation in the decimal module should round using the round-half-even algorithm (regardless of the rounding setting in the current context). It doesn't appear to do so: >>> from decimal import * >>> getcontext().prec = 6 >>> Decimal(9123455**2).sqrt() Decimal("9.12345E+6") The exact value of this square root is exactly halfway between two representable Decimals, so using round-half-even with 6 digits I'd expect the answer to be rounded to the neighboring representable Decimal with *even* last digit---that is, Decimal("9.12346E+6") This bug only seems to occur when the number of significant digits in the argument exceeds the current precision (indeed, if the number of sig. digits in the argument is less than or equal to the current precision then it's impossible for the square root to be halfway between two representable floats). It seems to me that this is a minor bug that will occur rarely and is unlikely to have any serious effect even when it does occur; however, it does seem to be a deviation from the specification. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1725899&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com