Wouldnt a NaN (Not a number) be more "matematically correct" result (I saw that on an old book about i387)
Matematically division by zero is an "mathematical impossibility", so NaN would be more logical Is there a way to deal with NaN's and other i387 (and similars) conventions directly in Pascal ? Something like : If A / B = NaN then something(); 2009/10/18 Tom Verhoeff <t.verho...@tue.nl> > On Sat, Oct 17, 2009 at 01:57:28PM +0200, Bart wrote: > > > > Is there a reason why in fpc both floating point and integer division > > by zero raise an EDivByZero exception? > > > > See: http://docwiki.embarcadero.com/VCL/en/SysUtils.EZeroDivide > > > > SysUtils.EZeroDivide exception is raised when an application attempts > > to divide a floating-point value by zero. > > Note: Integer divide-by-zero errors raise the SysUtils.EDivByZero > exception. > > It would be nicer if one had the ability to make floating-point division > by zero return an IEEE 754 plus/minus infinity, without raising an > exception. This is e.g. useful when one needs to evaluate rational > functions. Without such an infinity, you need to make a nasty case > analysis, which furthermore depends on the rational function. > > 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<http://www.cs.berkeley.edu/%7Ewkahan/ieee754status/why-ieee.pdf> > > > > for other examples and further motivation. > > Unfortunately, many compilers still do not fully support the IEEE 754 > floating-point standard. > > Best regards, > > Tom > -- > E-MAIL: T.Verhoeff @ TUE.NL | Dept. of Math. & Comp. Science > PHONE: +31 40 247 41 25 | Technische Universiteit Eindhoven > FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven > http://www.win.tue.nl/~wstomv/ <http://www.win.tue.nl/%7Ewstomv/> | The > Netherlands > _______________________________________________ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal