Skip to content

math/big: Exp function returns puzzling results when exponent = 1 #9826

@royalfork

Description

@royalfork

I'm using Go 1.4 on 64 bit Debian.

I run the following:
import "math/big"
a := new(big.Int).Exp(big.NewInt(5), big.NewInt(1), big.NewInt(3))

I expect 'a' to be 2, because 5**1 % 3 = 5 % 3 = 2. Instead, Go gives a = 5.

Code can be found here: http://play.golang.org/p/TCWWiXXZhf

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions