Expression Bug - Division by Zero

Hello

Am I missing something or is there a bug in “expression” component? I want to evaluate list of numbers a and return 0 if a==0 or r/a in other cases. But the expression tries to divide by 0 even tho I get rid of it using condition.
When I use regular components, it works just as expected.

expression_bug.gh (19.4 KB)

1 Like

Hi - I’ve added this to the list as RH-61477 to be looked at.
-wim

1 Like

The If() statement in the expression language is a function rather than a true conditional statement. Meaning both the TRUE and the FALSE values must be computed when it is called.

At the moment the only way around this would be to add a Max function into the FALSE argument:
If(a=0, 0, r / Max(a, 1))

3 Likes

You can use: a^(-1) which return +Infinity when a=0

If(a=0,0,r*a^(-1))

4 Likes