Skip to content

fix: decode a uint64 past max int64 as a positive float - #407

Open
SashaMIT wants to merge 1 commit into
vmihailenco:v5from
SashaMIT:fix/uint64-float-sign
Open

SashaMIT wants to merge 1 commit into
vmihailenco:v5from
SashaMIT:fix/uint64-float-sign

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 2, 2026 •

Copy link
Copy Markdown

Summary

DecodeFloat64 and DecodeFloat32 turned a uint64 through int64 first. 9223372036854775808 came back as -9223372036854775808, and 18446744073709551615 came back as -1. Both are positive values that fit in a float. A uint64 is now converted with its own magnitude. 42 is still 42. -3 is still -3.

Test plan

  • TestDecodeUint64AsFloat fails on tip: DecodeFloat64(9223372036854775808) = -9.223372036854776e+18
  • The same test passes after the change
  • go test -count=1 ./... passes

DecodeFloat64 and DecodeFloat32 cast the uint64 through int64 first.
9223372036854775808 came back negative, and 18446744073709551615 came back as -1.
A uint64 is converted with its own magnitude. 42 and a negative int64 are unchanged.
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.

1 participant