math/big's big.Int has a power function:

I wrote a power function for big.Float you can find 
It doesn't check for overflows because I don't think big.Float overflows 
from 64 bit exponents though maybe it could from a big enough base.

On Wednesday, 11 July 2012 06:22:15 UTC+3, Ondekoza wrote:
> How do I idiomatically calculate "the power of" with integers?
> z := 3^4 // Nooo, ^ caret is bitwise negation
> z := 3**4 // Nooo, invalid indirect
> z := math.Pow(3,4) // Correct, but converting 3 and 4 to float, and the 
> result.
> BigInt? I cannot provide an example, because I cannot understand from the 
> docs how to convert a 3 to a Bigint.
> Is the big package (using ints) better or converting to float first (using 
> the math-package)? 
> Would you see 2^x as a special case (using shifting)?

You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to