Math operators not giving the expected result

Hi, I’m running into a bit of a beginners error. (I guess) I’m having trouble with the math operators in Dynamo and am looking to understand an unexpected results.

I’m using a list of lengths and want to check if they are larger than a specific value. In this list there multiple items which are equal to the number I’m checking against; I would expect that I would get a False return on those items but somehow I’m getting true.


(I’m using the ‘>’ but I’m getting the same result in code block x>y?true:false;)

This only seems to happen to me on this list of lengths. When recreating the list in a code block I cannot replicate the effect. Also the ‘==’ node seems to work fine, but the ‘<’ & ‘>’ do not.
The value type of both inputs seem to be a double (checking with the Object.Type node). The original input of x has been a value of type length in the unit mm.

Could anyone help me understand why I’m getting these results?

Thank you kindly!

Try using a Math.Floor before the greater than node. There is a chance that your 4000 parameter value is actually 4000.0000000000000000000000000001 or something similar. Revit will only show decimals to the 10 place (I think) but it will still calculate past that.

Edit:
You can also round to a given number of decimals if you do not want round down. Not sure of the node off the top of my head.

3 Likes

Try using a Number node rather than the number slider. It would be odd for it to be a rounding error since the parameter value doesn’t even have a decimal, seems like it’s a whole number.

1 Like

Yes! Rounding the list values did the trick! (Might be an internal unit conversion issue?)
afbeelding

Thank you both for your help Steven and Sean! It’s great you guys help others out starting with Dynamo.

1 Like