Repository navigation
docs: explain NewFromFloatWithExponent rounding - #482
Open
ZXLyyds100 wants to merge 1 commit into
Open
ZXLyyds100 wants to merge 1 commit into
ZXLyyds100 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #276.
Summary
Clarify what
expmeans inNewFromFloatWithExponent:10^exp, with halfway values rounded away from zero.float64value, which can differ from the decimal literal.The GoDoc now shows
123.456with exponents-2,0, and2, producing123.46,123, and100. An executable example checks those outputs and the exact halfway inputs150and-150at exponent2.This is a documentation clarification, not a runtime fix. The existing implementation already produces these results. Only the function comment and an example test change; the algorithm, dependencies, minimum Go version, and CI configuration are unchanged.
Validation
Locally on Go 1.25.4, macOS arm64:
go doc NewFromFloatWithExponentbefore and after: the original comment only demonstrated a negative exponent; the updated comment explains all three cases.go test -run '^(TestNewFromFloatWithExponent|ExampleNewFromFloatWithExponent)$' -count=1 -vgo test -count=1 ./...go test -race -count=1 ./...go vet ./...go build ./...golangci-lint run --timeout=10m ./...(v2.14.0; zero issues)gofmtandgit diff --checkOther Go versions and operating systems were not run locally. Hosted CI and maintainer review are separate from these local results.
AI assistance: the patch and this text were prepared with OpenAI Codex. The changes received an agent self-review; no independent human review is claimed.