-
Notifications
You must be signed in to change notification settings - Fork 85
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
Make almost_eq return false if a and/or b is NaN #237
Make almost_eq return false if a and/or b is NaN #237
Conversation
This is certainly more correct. However, I notice that there's some inconsistency with using Would you be willing to write this method as simply a wrapper to appropriate call in a.abs_diff_eq(b, other) A bigger ask would be to drop the requirement on |
54e2176
to
046586c
Compare
I implemented the
I agree, it seems feasible. Is there a particular reason for dropping the approx dependency though? It seems to be a widely-used crate and is pretty lightweight. |
I see two areas needing fix, but the first would solve both issues
I pushed the first here to fix, but perhaps it makes more sense to test EDIT: forgot to say where handling INF would work in in line item 1 |
Doesn't this code now return true for |
🤦🏼, thanks for catching. I think I'm just getting antsy for the release and quickly merged the changes I pushed. I shouldn't be skipping the chance for peer review. On a related note, do you mind if I push (no force) on your fork's branches that have open PRs? I didn't think to ask before, but it seems like a courtesy to request that permission. |
perhaps a == b || a.abs_diff_eq(&b, acc) would be more appropriate. |
It's a small change which doesn't usually warrant a full review. It's just a mistake, and mistakes happen. No big deal.
Thank you for asking, but I don't mind at all. I would've disabled it via GitHub if it did bother me.
Sure, that should work. Might read better as if a.is_infinite() && b.is_infinite() {
return a == b;
} though. |
Appreciate you saying that.
Ah, the intent is more explicit. |
I feel like this might have been a typo because the docs say that
almost_eq
always returnsfalse
if either number is NaN. It also seems correct thatalmost_eq(NaN, x)
is always false.