How to best do fuzzy comparison for floats #5826
Answered
by
abadams
define-private-public
asked this question in
Q&A
-
I was porting an algorithm from C++ over to use Halide. At some point in the algorithm, there was this
I know that is can be a little dangerous to compare floats to exact numbers, which is why you should do fuzzy comparison. Is there a recommended way to do this in Halide? |
Beta Was this translation helpful? Give feedback.
Answered by
abadams
Mar 16, 2021
Replies: 1 comment
-
There's no Halide-specific way to handle this. The idioms are similar to C/C++. Depending on what kind of error I'm being robust to, I usually do something like |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
alexreinking
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's no Halide-specific way to handle this. The idioms are similar to C/C++. Depending on what kind of error I'm being robust to, I usually do something like
abs(f) < 0.001f