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

math/big: comment typo #68466

Closed
With-Sky opened this issue Jul 16, 2024 · 3 comments
Closed

math/big: comment typo #68466

With-Sky opened this issue Jul 16, 2024 · 3 comments
Labels
Documentation Issues describing a change to documentation. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@With-Sky
Copy link
Contributor

With-Sky commented Jul 16, 2024

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.

@randall77 randall77 added Documentation Issues describing a change to documentation. help wanted labels Jul 16, 2024
@randall77 randall77 added this to the Unplanned milestone Jul 16, 2024
@cherrymui cherrymui added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 16, 2024
@cherrymui
Copy link
Member

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.

With-Sky added a commit to With-Sky/go that referenced this issue Jul 17, 2024
Comment in line 395: [x₀ < S, so S - x₀ < 0; drop it], should be [x₀ < S, so S - x₀ > 0; drop it].

The proof is based on S - x₀ > 0, thus it's a typo of comment.

Fixes golang#68466
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/598855 mentions this issue: math/big: fix comment typo in natdiv.go

@gabyhelp
Copy link

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@dmitshur dmitshur modified the milestones: Unplanned, Go1.23 Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues describing a change to documentation. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants