[ python-Bugs-1388949 ] Decimal sqrt() ignores rounding

SourceForge.net noreply at sourceforge.net
Fri Dec 23 16:11:26 CET 2005


Bugs item #1388949, was opened at 2005-12-23 08:11
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=1388949&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: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Adam Olsen (rhamphoryncus)
Assigned to: Nobody/Anonymous (nobody)
Summary: Decimal sqrt() ignores rounding

Initial Comment:
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

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1388949&group_id=5470


More information about the Python-bugs-list mailing list