-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
math/big: incorrect result from Exp on 386 architecture #13515
Comments
Just noticing that you @ncw closed this already. Not a bug? (Haven't looked into it yet). |
This is a legitimate issue. I'm seeing the same behavior with different values: package main
import (
"fmt"
"math/big"
)
func main() {
x, _ := new(big.Int).SetString("b62ca285f97d2532089ea7b6c0795e692c5105f316c65a5cbdd4719dd20162b6b42ceab81f1178111fa981c05602bdf7ae274891ba35a53cb01784fbf0e612658baa96c07e7026374bed5d71e49a19c44c4da22b6ca4d6fe98de28291cc5b64f", 16)
y, _ := new(big.Int).SetString("3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c", 16)
p, _ := new(big.Int).SetString("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", 16)
fmt.Printf("x: %x\ny: %x\np: %x\n", x, y, p)
fmt.Printf("result: %x\n", new(big.Int).Exp(x, y, p))
} Output:
result: 77c873fcee4663289da06a660417b6a9831c77875632199b2d1c0f4372606c84
result: ef03bdbf3d5e1c37142f762042f3c49d3e1ba5a71ba1e238c54aa913b00fbe4f EDIT: I should note the amd64 result is the correct one. |
Yes, it's a real bug. I am preparing a fix CL. |
CL https://golang.org/cl/17673 mentions this issue. |
CL https://golang.org/cl/17672 mentions this issue. |
Also fix bug reported in CL 17510. Found during fix of #13515 in CL 17672, but separate from the fix. Change-Id: I4b1024569a98f5cfd2ebb442ec3d64356164d284 Reviewed-on: https://go-review.googlesource.com/17673 Reviewed-by: Robert Griesemer <[email protected]>
I wonder if this is related to this case: http://play.golang.org/p/QVWwgKMdCu ? Should I open separate issue for this matter? Thanks. |
@ysmolsky, thanks. I will file a new issue. |
Thanks, Russ! |
CL https://golang.org/cl/18585 mentions this issue. |
…tgomery code Fixes #13515. Change-Id: I7dd5fbc816e5ea135f7d81f6735e7601f636fe4f Reviewed-on: https://go-review.googlesource.com/17672 Reviewed-by: Robert Griesemer <[email protected]> Reviewed-on: https://go-review.googlesource.com/18585
I get different results whether I run it in amd64 mode or 386 mode
The first one is correct (you can verify this with python thus)
The playground also gives the incorrect results.
Tested with go 1.5.1 and tip
The text was updated successfully, but these errors were encountered: