[issue7049] decimal.py: Three argument power issues

Stefan Krah report at bugs.python.org
Mon Feb 22 21:05:46 CET 2010

Stefan Krah <stefan-usenet at bytereef.org> added the comment:

I've tried to pinpoint exactly what I don't like about the current
behavior, and the main reason is that it violates my mental model
of how the functions in the specification generally behave:

1) Functions take arbitrary precision input.

2) Functions try to preserve as much of the exponent
   information of the input as possible.

With these in mind, it's easy to specify powmod() as:

(a ** b) % c, calculated with unlimited precision. Raises if
the final result does not fit in the current precision.

It is not totally clear to me why the result should have exponent 0
because it is an integer. Decimal("1E3").to_integral() also preserves
the exponent information.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list