[fpc-pascal] Division by Zero: EDivByZero and EZeroDivide

Gustavo Enrique Jimenez gejimenez at gmail.com
Mon Oct 19 19:57:10 CEST 2009


2009/10/18 Tom Verhoeff <T.Verhoeff at tue.nl>:
> A simple example is the situation where one needs to calculate
> the replacement resistor value R for parallel resistors having
> values R1, R2, ..., Rk.  The formula is R = 1/(1/R1 + 1/R2 + ... + 1/Rk).
> The formula gives a divide-by-zero if one of the resistors has value 0.
> But in that case, the replacement value R also equals 0.  When allowing
> infinities, it just works out fine (infinity + x = infinity, 1/infty = 0).
> That is precisely why IEEE 754 has infinities.  Also see
>
>        <http://www.cs.berkeley.edu/~wkahan/ieee754status/why-ieee.pdf>
>
> for other examples and further motivation.

Mmm... the formula R = 1/(1/R1 + 1/R2 + ... + 1/Rk) is only valid if
none of Rn=0.
Programmers can and must take care of that situation.

Gustavo



More information about the fpc-pascal mailing list