I just got a bug in my program which happens because:
result = (a-b) / c
in some cases a-b might result in 0, and hence it is trying to:
0 / c
I can, and will make necessary cautions to avoid this happening, but does there happen to be some simple way, perhaps even a command that would result in 0 when division by zero happens?
simple way to avoid division by zero?
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: simple way to avoid division by zero?
Simple way to avoid division by zero? What about
Code: Select all
If c <> 0 Then result = (a-b) / c Else result = 0
Re: simple way to avoid division by zero?
ah. what a silly thing i didnt realise it be that simple.