Math/big integer exponentiation modulo prime with negative exponent

I am running into a minor issue while using the math/big big integer library. According to the documentation, it should work perfectly fine with negative exponents so long as the modulus is non-zero. However, when running the following piece of code, I get a printed result of 1, instead of the expected result 16. Am I misunderstanding the documentation or doing something wrong? I am using go version 1.10.3 linux/amd64.

package main

import "math/big"
import "fmt"

func main() {
	fmt.Printf("%v\n", new(big.Int).Exp(big.NewInt(28), big.NewInt(-3), big.NewInt(47)))

It prints 16. Could you update to the latest version and try it out?

Tried in in the latest released version (1.11.2 linux/amd64), and now it behaves as expected (I am getting 16). Was this a change for version 1.11, I couldn’t find it in the changelogs?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.