Jump to content

When are equal values are NOT equal?


Recommended Posts

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?

 

Link to comment
Share on other sites

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.

 

 

  • Thanks 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...