Skip to content
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

fmt: go1.9 does not properly process big integer #23509

Closed
Codefor opened this issue Jan 22, 2018 · 5 comments
Closed

fmt: go1.9 does not properly process big integer #23509

Codefor opened this issue Jan 22, 2018 · 5 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@Codefor
Copy link

Codefor commented Jan 22, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build626720835=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

package main

import (
    "fmt"
)

func main() {
    var (
        a int64 = 83520398946977
        b int64 = 23200110818
        c int64 = 3600
    )

    //shows 3600, expected 3600
    fmt.Println(a / b)

    //shows 83520398944800, expected 83520398946977
    fmt.Println(b * c)

    //shows false, expected true
    fmt.Println(a == b*c)
}

What did you expect to see?

a = b*c

What did you see instead?

a != b*c
c != a/b

@mvdan
Copy link
Member

mvdan commented Jan 22, 2018

shows 83520398944800, expected 83520398946977

Where did you get that "expected" value? I tried calc as well as Google and they both give 83520398944800.

This value is within the bounds of an int64, and these aren't really big ints, so I would be very surprised if Go was actually wrong here.

@mvdan mvdan added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 22, 2018
@randall77
Copy link
Contributor

Yes, I would agree that your expectations are wrong.

@Codefor
Copy link
Author

Codefor commented Jan 23, 2018

//shows 3600, expected 3600
fmt.Println(a / b)

Here a/b = 3600, which c is 3600.So shouldn't b *c equals to a?

https://play.golang.org/p/1Y9wPCerkDd

@mvdan @randall77

@Codefor
Copy link
Author

Codefor commented Jan 23, 2018

sorry,I see.

a % b != 0

@mvdan
Copy link
Member

mvdan commented Jan 23, 2018

Remember to use https://github.com/golang/go/wiki/Questions for questions - the issue tracker is just for bugs and proposals.

@mikioh mikioh changed the title go1.9 does not properly process big integer fmt: go1.9 does not properly process big integer Jan 26, 2018
@golang golang locked and limited conversation to collaborators Jan 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants