avoid divide by zero  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Gravityz
Posts: 755
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2026.3
Location: Netherlands
Contact:

avoid divide by zero

Post by Gravityz »

is there an easy wat to avoid divide by zero?

i am substracting 2 temp values and divide those by another substracion value.
that value can be +, - or even zero

is there an easy way to avoid divide by zero or can this only be done by first doing an if then check before i divide by zero?
User avatar
gizmocuz
Posts: 3026
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: avoid divide by zero

Post by gizmocuz »

Yes, first check if "another substracion value" is not zero, if it is zero, do not divide
Quality outlives Quantity!
Gravityz
Posts: 755
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2026.3
Location: Netherlands
Contact:

Re: avoid divide by zero  [Solved]

Post by Gravityz »

thanks. thought there might be an easy fix but this will work
Post Reply