What's the trouble with this expression (if..)?

Version 6 SR13
(6.13.19058.371, 02/27/2019)

I assume you have to flatten the tree into a list somewhere after the subtraction component.


I’m trying to filter some numbers to avoid a division by zero, I tried another way with the “Equals” component, but it has the same problem. I thought Rounding the numbers could help, but the truth looks to be elsewhere…
Unfortunately I have to preserve the data tree structure

Oh :frowning:. Unfortunately I do not understand data trees that much.
Perhaps try using scripting components and remove all values that equal 0 (zero).

can you post an example file with the numbers/data you are using?

I think it is a rounding issue. The equal is the same case as your first example where you may be checking 0 vs 0.00001

mystery.gh (7.6 KB)
Here are the data I’m using

Remember you simply can’t trust floating point numbers.

mystery_re.gh (18.2 KB)

both @HS_Kim and @Adam_M are correct. It is a rounding issue. Just add the formula that @Adam_M provided above into your expression component. (after the abs component in your def)

Thanks for the tip, yes it is a mystery! :thinking:

It is no mystery :smiley: https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

It is pretty common knowledge in computational design, engineering, architecture, etc. you should consider everything as tolerance based, not absolute. Even Rhino itself is tolerance based (See Options>Units in Rhino to see your tolerances). Long story short, unless you are using integers, never ask if A=B, always ask if abs(A-B)<tolerance