# Divide By 0, breaks Try()?

**URL:** <https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [March 5, 2018, 10:17pm UTC](https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237 "2018-03-05T22:17:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![john.furby](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@john.furby](https://forum.inductiveautomation.com/u/john.furby)\
**Post date:** [March 5, 2018, 10:17pm UTC](https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237/1 "2018-03-05T22:17:22Z")

</div>

So I have a tag that occasionally will be NAN in the PLC. This could be for a number of reasons, most of which involve a bad comm or a Divide by 0. Ignition will then read the tag as a bad quality and putting a try() function on the expression does not seem to help hide the bad data. When this tag is being divided by 0, the equipment has not been run yet so its efficiency really should show NAN or something equivalent. Other HMIs will show some kind of letter value for these kinds of conditions. Is there a way that Ignition can deal with this condition? Why does a try statement seem to fail?

Please help.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 5, 2018, 10:26pm UTC](https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237/2 "2018-03-05T22:26:50Z")

</div>

This was fixed in version 7.9.5. What version are you running?

---

<div class="post-metadata">

**Author:** ![john.furby](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@john.furby](https://forum.inductiveautomation.com/u/john.furby)\
**Post date:** [March 5, 2018, 10:37pm UTC](https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237/3 "2018-03-05T22:37:52Z")

</div>

7.9.5

Are you referring to the Try statement or the actual tag itself?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 5, 2018, 11:21pm UTC](https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237/4 "2018-03-05T23:21:45Z")

</div>

Okay, the ticket I was thinking of involved the `try` expression and division by `None`, but division by `zero` is a bit odd, resulting in a Tag Eval Error quality…

---

<div class="post-metadata">

**Author:** ![john.furby](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@john.furby](https://forum.inductiveautomation.com/u/john.furby)\
**Post date:** [March 5, 2018, 11:42pm UTC](https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237/5 "2018-03-05T23:42:02Z")

</div>

Hmm, so the tag should not show bad quality (Tag Evaluation Error) when showing ‘1.$’ in the PLC (Legacy Allen-Bradley ControlLogix divide by zero)?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 5, 2018, 11:45pm UTC](https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237/6 "2018-03-05T23:45:57Z")

</div>

No, sorry, I never really finished my thoughts.

The current behavior where the tag gets a `Tag Eval Error` seems to be the intended behavior. The `try` function has no effect because the divide by zero isn’t throwing any error, it results in a value of `Infinite`, which somewhere down the line gets considered an illegal value for the tag.

---

<div class="post-metadata">

**Author:** ![martinel3746](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@martinel3746](https://forum.inductiveautomation.com/u/martinel3746)\
**Post date:** [March 5, 2018, 11:55pm UTC](https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237/7 "2018-03-05T23:55:59Z")

</div>

Good to know, thanks.  
You might try using a tag changed event script on problem tags with something like:  
**if initialChange==True:**  
** system.tag.write( ‘[.]thisTag’, 0.00001 )**

---

<div class="post-metadata">

**Author:** ![john.furby](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@john.furby](https://forum.inductiveautomation.com/u/john.furby)\
**Post date:** [March 5, 2018, 11:56pm UTC](https://forum.inductiveautomation.com/t/divide-by-0-breaks-try/17237/8 "2018-03-05T23:56:34Z")

</div>

Ok, so isNull() seems to work.
