3-arg float pow()

Markus Schaber markus at schabi.de
Wed Sep 12 04:03:51 EDT 2001


Hi,

David C. Ullrich <ullrich at math.okstate.edu> schrub:

>>> Seems like pow(3., 500., 7.) can't possibly do anything except just
>>> 3.**500. % 7(???), hence the random nature of the result and the
>>> utter uselessness.
>>
>>[Markus Schaber]
>>> The trick is that it is a exponential function with large result
>>> modulo a small number. (such operations are e. G. used in the RSA
>>> crypto algorithm)
>>> ... [and an explanation of the modular square-and-multiply method]
>>> ...
>>
>>I'm sure David knows all that.
> 
> I was pretty sure I knew all that - if _you_'re
> sure I did then I'm certain I did...<g>.
> Could be telepathy, could be the fact that
> I mentioned the algorithm in my post, who knows.

:-)
 
>> He's responding specifically to that these
>>are not integers, but floating-point numbers.

I'm rather shure that one could also apply those algorithms to FP 
calculations, eventually loosing some of the speed of the hardware FPU.

But in lots of cases, FP pow in this way doesn't make much sense, so I 
think one can do without it.

markus
-- 
"The strength of the Constitution lies entirely in the determination of 
each citizen to defend it. Only if every single citizen feels duty 
bound to do his share in this defense are the constitutional rights 
secure." -- Albert Einstein



More information about the Python-list mailing list