[Python-bugs-list] [ python-Bugs-457066 ] pow(a,b,c) should accept b<0

noreply@sourceforge.net noreply@sourceforge.net
Thu, 30 Aug 2001 18:17:23 -0700


Bugs item #457066, was opened at 2001-08-30 18:17
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=457066&group_id=5470

Category: Python Library
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: pow(a,b,c) should accept b<0

Initial Comment:
You should be able to raise integers to negative powers
mod n.  If b<0, pow(a,b,c)==pow(pow(a,-1,c),-b,c)
where pow(a,-1,c) is a's multiplicative inverse mod c,
computed with the extended Euclid algorithm.  This
would be in Python's spirit of math completeness and
would save people from the trouble of having to figure
out the algorithm over and over.  

I can come up with a patch for this if it's agreed on
as desirable.


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

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