Issue 1388949: Decimal sqrt() ignores rounding (original) (raw)

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