Skip to content

fix: parse integers with matching bit size instead of 0 (#217) - #377

Open
Yshuro wants to merge 1 commit into
spf13:masterfrom
Yshuro:fix/issue-217
Open

Yshuro wants to merge 1 commit into
spf13:masterfrom
Yshuro:fix/issue-217

Conversation

@Yshuro

@Yshuro Yshuro commented Nov 20, 2026

Copy link
Copy Markdown

Problem

On 32-bit architectures (such as arm32, 386), strconv.ParseUint and strconv.ParseInt called with bitSize = 0 constrain the accepted value range to the architecture's native int/uint bit size (32 bits). As a result, casting string representations of 64-bit values such as "18446744073709551615" (ToUint64E) or "9223372036854775807" (ToInt64E) fails with value out of range.

Solution

  • Set the appropriate bitSize (8, 16, 32, 64) in parseInt and parseUint based on type T, reserving 0 for architecture-dependent int/uint.
  • Add unit tests in number_test.go verifying boundary parsing across 32-bit and 64-bit architectures.

Fixes #217

Signed-off-by: Yshuro <yshuro1080@gmail.com>
@CLAassistant

CLAassistant commented Nov 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

cast string to uint64 and uint32 failed on arm32

2 participants