Can we multiply by

**0.333333**instead of divide by

**3**.

I want to avoid the division by zero error, and since I'm multiplying by a fixed value, I was hoping that this could resolve the problem.

- arnie
**Posts:**1589**Joined:**11 Feb 2009**Location:**Portugal**Has thanked:**478 times**Been thanked:**509 times

I was never a math enthusiastic so I apologise for this question :

Can we multiply by**0.333333** instead of divide by **3**.

I want to avoid the division by zero error, and since I'm multiplying by a fixed value, I was hoping that this could resolve the problem.

Can we multiply by

I want to avoid the division by zero error, and since I'm multiplying by a fixed value, I was hoping that this could resolve the problem.

- TJ
**Posts:**6636**Joined:**29 Aug 2006**Location:**Global Citizen**Has thanked:**971 times**Been thanked:**1919 times

- TJ
**Posts:**6636**Joined:**29 Aug 2006**Location:**Global Citizen**Has thanked:**971 times**Been thanked:**1919 times

I was never a math enthusiastic so I apologise for this question :

Can we multiply by0.333333instead of divide by3.

I want to avoid the division by zero error, and since I'm multiplying by a fixed value, I was hoping that this could resolve the problem.

How does this avoid the division by zero error? If you are using a variables as follows:

a = x/b;

and you wanted to avoid a division of zero with b = 0 then using multiplication will not make any difference. Reason is to convert the above to a multiplication you would have:

a = x * reciprocal(b);

Guess what? When b = 0 then you still get a division by 0 error. The only way to avoid the error is to have a test as follows:

if b <> 0 then begin

- a = x/b;

- do something else and/or print a warning message and/or alert and/or halt

"something else" could be setting "a" to a very large value, such as:

a = 100000000;

but that depends on the subsequent use of the variable "a".

end;