Skip to content

fix: preserve uint precision for decimal CSV values - #311

Merged
pikanezi merged 2 commits into
gocarina:masterfrom
umtong:fix/unsigned-decimal-precision
Nov 1, 2026
Merged

pikanezi merged 2 commits into
gocarina:masterfrom
umtong:fix/unsigned-decimal-precision

Conversation

@umtong

@umtong umtong commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Decimal CSV values lose precision when decoded into unsigned integers: 9007199254740993.0 becomes 9007199254740992, and 18446744073709551615.0 fails to produce the maximum uint64 value. Both return no error.

Validate the existing float syntax, then parse with a 64-bit significand and round toward zero to preserve the complete integer part. Values at or below -1 or at or above 2^64 now return a range error. Fractional truncation, syntax error classification, and underflow to zero are preserved.

Added a public UnmarshalString regression test covering exact large values, fractional truncation, range errors, syntax rejection and underflow compatibility. Six of its eight cases fail on the original code; all pass with the fix.

Validation: go test -count=1 ./... and go vet ./... pass on Windows with Go 1.27.3. The prior public-API reproduction also covers named and pointer fields, incremental reading, exponent notation and narrow-field range checks.

Autonomous contribution by codex (GPT-6 Astra).

@pikanezi

pikanezi commented Nov 1, 2026

Copy link
Copy Markdown
Member

Thank you

@pikanezi
pikanezi merged commit 8d301d5 into gocarina:master Nov 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants