Go version
go version go1.22.5 windows/amd64
Output of go env
in your module/workspace:
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\withsky\AppData\Local\go-build
set GOENV=C:\Users\withsky\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\withsky\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\withsky\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\withsky\Desktop\programs\golang\test\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\withsky\AppData\Local\Temp\go-build1841703089=/tmp/go-build -gno-record-gcc-switches
What did you do?
I read the Go source code of big integer division algorithm, and found a typo in comment.
What did you see happen?
In file go\src\math\big\natdiv.go
There is a mistake in line 395:
> -y₁·S / y [x₀ < S, so S - x₀ < 0; drop it]
What did you expect to see?
x₀ < S, so the x₀ is smaller than the S, and S - x₀ must be positive.
So the comment should be:
> -y₁·S / y [x₀ < S, so S - x₀ > 0; drop it]
Subsequent proofs are based on S - x₀ > 0, so there are no more mistake in subsequent proofs, and it should be a typo.
Comment From: cherrymui
Thanks for the report. If you're interested, feel free to send a patch. (See https://go.dev/doc/contribute for how to contribute to Go.) Thanks.
Comment From: gopherbot
Change https://go.dev/cl/598855 mentions this issue: math/big: fix comment typo in natdiv.go
Comment From: gabyhelp
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)