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

relax float equality comparison #5

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

Conversation

smanilov
Copy link

@smanilov smanilov commented Dec 2, 2024

The included test seems to lead to an infinte loop, due to a bug in the rand package, version 0.8.5. The bug is fixed in rand version 0.9, but that version is not released yet.

Either way, it can be worked around, if care is taken when to sample a uniform distribution. This commit samples a uniform distribution only if the absolute difference between the two numbers is greater than 1e-6 parts of the smaller one (1%%%). Otherwise, it assumes that the numbers are the same and just uses the smaller one.

The included test seems to lead to an infinte loop, due to a bug in the
`rand` package, version `0.8.5`. The bug is fixed in `rand` version
`0.9`, but that version is not released yet.

Either way, it can be worked around, if care is taken when to sample a
uniform distribution. This commit samples a uniform distribution only if
the absolute difference between the two numbers is greater than 1e-4
parts of the smaller one (1%%). Otherwise, it assumes that the numbers
are the same and just uses the smaller one.
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