try(4/0,99)
Is there anyway to stop dividing by zero errors?
try(4/0,99)
Is there anyway to stop dividing by zero errors?
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.
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
if(!{[.]HL} && !{[.]LL}, 0, abs(({[.]HL} +{[.]LL}) / 2) * 100))
if(!{[.]HL} && !{[.]LL}, 0, abs(({[.]HL} +{[.]LL}) / 2) * 100)