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

Random hash_value for mpfr_float(0) #593

Open
fintarin opened this issue Feb 6, 2024 · 0 comments
Open

Random hash_value for mpfr_float(0) #593

fintarin opened this issue Feb 6, 2024 · 0 comments

Comments

@fintarin
Copy link

fintarin commented Feb 6, 2024

The hash_value for mpfr_float constructed from zero int is random. Thus, hash_value(mpfr_float(0)) != hash_value(mpfr_float(0)). The problem is related to data()[0]._mpfr_d - code.

When debugging hash_function(mpfr_float(0)) I get various random _mpfr_d such as:

  • {0,8461470348308866388,7019261819594830956,7163369272283972460,8391161944126416233,8031153322401625088,8021807474101977202,8319401290704975468,7146776104407163694}
  • {0,7308619195232122478,7954879178731648110,7598805559586157151,3414698781512329070,3417225383054243439,8021807474102005619,8319401290704975468,7146776104407163694}

I assume that _mpfr_d holds an uninitialised values when the number is initialised with zero. So to fix this, you should check is_zero in the hash_value function. Also, the same problem can occur with other special values such as infinity and nan.

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

No branches or pull requests

1 participant