Steadicam Posted June 30, 2022 Share Posted June 30, 2022 I was trying to confirm equal values between two parameters that need to be equal to affect another node's logic. For example, both values in the node are 60 and I need to confirm that both values are 60. These values are derived from angles that have been measured between points. However, to my surprise I cannot get these two integers to be seen as equal no matter how hard I try. I can't for the life of me figure out if this is a bug, the result of some bad formatting or math upstream, or some kind of strange behavior in Houdini that maybe someone can shed some light on. I have done some expressions and math upstream to produce these values but ultimately the parameter displays the value as an integer of "60". No matter what I do I cannot get the following to produce true despite both parameters displaying the same number. ch("Value1") == ch("Value2") This of course works: ch("Value1") == ch("Value1") Somehow I show that. ch("Value1") < ch("Value1") How can that be? Are there any "normal" ( read not a bug) conditions that might produce this that anyone is aware of? Quote Link to comment Share on other sites More sharing options...
madebygeoff Posted June 30, 2022 Share Posted June 30, 2022 Could they be floating point rounding errors? Sometimes you can create situations where two numbers that looks (or more maddeningly) SHOULD be equal, can be different because of how floating point numbers are handled. Click on the label of the parameter value for each to fully expand the number to full decimal places and see if they are the same or not. 1 Quote Link to comment Share on other sites More sharing options...
Fenolis Posted July 5, 2022 Share Posted July 5, 2022 For situations like this, instead of using an A == B comparison, you can instead do: if ( abs( A - B ) < 0.0001 ) 2 Quote Link to comment Share on other sites More sharing options...
Steadicam Posted July 7, 2022 Author Share Posted July 7, 2022 Perfect. Thanks! To confirm this was exactly what was going on. Rounding errors. Wasn't showing up in the expressions as there were multiple relative references and maths leading to these particular values so they only showed the expressions or the rounded values ( which all matched). Deleting the expressions revealed the true values. Quote Link to comment Share on other sites More sharing options...
doc Posted July 20, 2022 Share Posted July 20, 2022 If both parameters are integer parameters (ie not float parameters set to integer values) then you might try using the chi expression instead of ch. I believe ch returns a float, so it might be casting you integer to a float Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.