Integer exponentiation without modulo?

FX Coudert fxcoudert at gmail.com
Sun Mar 18 12:17:35 CET 2007


> If b is larger than an unsigned long int (which is at least 32 bits  
> in size (I believe 64 bits in a 64-bit system), hence it can store  
> an integer as large as 4294967295), that means you're computing a  
> number larger than b^4294967295, which even for the smallest choice  
> of base b = 2 is already 4 Gbits in size -- assuming optimal  
> storage. Are you really really sure you want to perform arithmetic  
> with numbers this large? Maybe you should reevaluate whatever it is  
> that you're doing.

I just wanted to write generic code without having to care about  
limits and special-casing b = -1, b = 0 and b = 1.  I ended up doing  
just that, anyway.

Thanks for the answer,
FX


More information about the gmp-discuss mailing list