Can "greater_or_equal" be used to comparing floating point values?
In the manual, the description of "equal" has a paragraph: "Please use almost_equal, equivalent_float_epsilon, or equivalent_float_ULP when comparing floating-point values.".
https://help.autodesk.com/view/BIFROST/ENU/?guid=Bifrost_Common_reference_amino_equal_html
"greater_or_equal" also has "equal", can it be used to compare floating-point numbers? or, it's better to use "less" logically instead? for example:
use
not(a < b)
instead of
a >= b
Solved! Go to Solution.
Solved by Grahame_Fuller. Go to Solution.
Hi,
Yes, greater_or_equal can be used with floating-point values. Whether or not it should be used is another question, and the answer depends on the exact situation.
The issue arises from the imprecision that is inherent in floating-point math. In brief, floating-point values can't represent real numbers exactly, and the more math operations that you perform on them, the farther they may drift from the exact real value. A value that "should" be 1.0, such as sin(pi/2), may actually be sin(something_close_to_pi/2) and evaluate as something like .99998. In such a case, comparing the result to 1.0 using greater_or_equal will yield false, even though the value should be 1.0 and therefore true.
Using almost_equal or the epsilon/ULP nodes allows you to declare how accurate you want the result to be, in other words, what you consider to be "close enough".
I hope that helps,
gray
Can't find what you're looking for? Ask the community or share your knowledge.