Try() expression doesn't catch dividing by zero?

try(4/0,99)

Is there anyway to stop dividing by zero errors?

1 Like

image

dividing by zero does throw an exception tho and the try function isn't catching it on the function above

this try(4/None,99) does render the failback value

Divide by None will throw an exception, divide by 0 is infinity, no exception thrown.

No, dividing by zero is supported fine in the expression evaluation:

The type conversion error is happening when the tag system receives the infinity from the expression and cannot coerce it to a value to apply to the tag. As in the link @jlandwerlen posted above.

2 Likes
abs(({[.]HL} - {[.]LL)) / (({[.]HL} + {[.]HL}) / 2) * 100

Maybe I can ask for more pointed help. I still want to render a percentage difference of '0' when both the HL and LL tag are zeros. Any ideas?

Use if() as demonstrated in the link posted above. Also see the docs.
https://docs.inductiveautomation.com/display/DOC81/if

1 Like
if(!{[.]HL} && !{[.]LL}, 0, abs(({[.]HL} +{[.]LL}) / 2) * 100))
2 Likes
if(!{[.]HL} && !{[.]LL}, 0, abs(({[.]HL} +{[.]LL}) / 2) * 100)