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.

classification
Title: Decimal sqrt() ignores rounding
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: facundobatista Nosy List: Rhamphoryncus, facundobatista
Priority: normal Keywords:

Created on 2005-12-23 15:11 by Rhamphoryncus, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg27136 - (view) Author: Adam Olsen (Rhamphoryncus) Date: 2005-12-23 15:11
Decimal Contexts' sqrt() method exhibits the same
rounding behavior irregardless of the rounding parameter.

>>> c = decimal.Context(rounding=decimal.ROUND_CEILING)
>>> f = decimal.Context(rounding=decimal.ROUND_FLOOR)
>>> cs =
decimal.Context(rounding=decimal.ROUND_CEILING, prec=14)
>>> fs = decimal.Context(rounding=decimal.ROUND_FLOOR,
prec=14)
>>> c.sqrt(D(2))
Decimal("1.414213562373095048801688724")
>>> f.sqrt(D(2))
Decimal("1.414213562373095048801688724")
>>> cs.sqrt(D(2))
Decimal("1.4142135623731")
>>> fs.sqrt(D(2))
Decimal("1.4142135623731")

It appears to always round up.


Python 2.4.2 (#2, Nov 20 2005, 17:04:48)
Debian unstable
msg27137 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2005-12-24 17:46
Logged In: YES 
user_id=752496

The rounding setting in the context is not used, always uses
the round-half-even algorithm, as specified in the Decimal
Specification (see
http://www2.hursley.ibm.com/decimal/daops.html#refsqrt).
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42722
2005-12-23 15:11:26Rhamphoryncuscreate