[issue45918] Possibly use ROUND_05UP in decimal's localcontext() example

2021-11-28 Thread Tim Peters
Tim Peters added the comment: I'll add that the rounding mode is intended to ease emulating fixed-point arithmetic. The decimal spec claimed that was a goal, but there really isn't any direct support for saying, e.g., "I want two digits after the decimal point". Only for specifying total pre

[issue45918] Possibly use ROUND_05UP in decimal's localcontext() example

2021-11-28 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Pyth

[issue45918] Possibly use ROUND_05UP in decimal's localcontext() example

2021-11-28 Thread Tim Peters
Tim Peters added the comment: Not a good idea in general - this rounding mode is _mostly_ "to zero", and isn't intended for chains of operations. I don't believe I've ever seen it used in a real program, so the current "no example at all" is a fair representation of real usage ;-) -

[issue45918] Possibly use ROUND_05UP in decimal's localcontext() example

2021-11-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: I’m concerned though that the intermediate calculations might be worse off than with some other rounding mode. -- ___ Python tracker ___ _

[issue45918] Possibly use ROUND_05UP in decimal's localcontext() example

2021-11-28 Thread Raymond Hettinger
New submission from Raymond Hettinger : Candidate example: with localcontext() as ctx: ctx.prec += 10# Perform a higher precision calculation ctx.rounding = ROUND_05UP # Avoid double rounding of the final calculation step s = calculate_something() s = +s