Community
Bifrost Forum
Welcome to the Bifrost Forum. This is the place for artists using Bifrost to ask and answer questions, browse popular topics, and share knowledge about creating effects procedurally using Bifrost. You can also visit the Bifrost Community on AREA to download an array of ready-to-use graphs, read Bifrost news and updates, and find the latest tutorials.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can "greater_or_equal" be used to comparing floating point values?

1 REPLY 1
SOLVED
Reply
Message 1 of 2
g2m.agent
302 Views, 1 Reply

Can "greater_or_equal" be used to comparing floating point values?

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

1 REPLY 1
Message 2 of 2
Grahame_Fuller
in reply to: g2m.agent

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

 


Grahame Fuller
Learning Content Developer

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report