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

Added Hashmap incrementFloatValue overflow check #927

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dograprabhav
Copy link

@dograprabhav dograprabhav commented Oct 2, 2024

Closes #921


inf := math.MaxFloat64

val, err = hmap.incrementFloatValue("field1", inf+float64(1e308))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just replaced this line with the below code and the test fails suggesting that the operation is giving no errors for field4 . Is this expected behaviour or am I missing something?

val, err = hmap.incrementFloatValue("field4", 1.0)
val, err = hmap.incrementFloatValue("field4", math.MaxFloat64)

Copy link
Author

@dograprabhav dograprabhav Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes very counter intuitive, but this is the expected behavior in Go.
https://en.wikipedia.org/wiki/IEEE_754

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.

Hashmap "incrementFloatValue" overflow check not working
2 participants