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

2009-10-19 Thread Jonas Maebe
On 18 Oct 2009, at 17:52, Tom Verhoeff wrote: 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. http://www.freepascal.org/docs-html/rtl/math/setexceptionmask.html Fully cross-platform, even

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

2009-10-19 Thread Bart
Hi all, Interesting thoughts. However, if we raise an exception, why do we raise EDivByZero instead of EZeroDivide? Note: EDivByZero = class(EIntError), so IMHO it makes no sense to raise it with a floating point error. Bart ___ fpc-pascal maillist -

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

2009-10-19 Thread Tom Verhoeff
On Sun, Oct 18, 2009 at 02:49:40PM -0200, Jorge Aldo G. de F. Junior wrote: > Wouldnt a NaN (Not a number) be more "matematically correct" result (I saw > that on an old book about i387) No, read Kahan's article that I pointed to. > Matematically division by zero is an "mathematical impossibility

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

2009-10-19 Thread Tom Verhoeff
On Mon, Oct 19, 2009 at 10:21:01AM +0200, Jonas Maebe wrote: > > On 18 Oct 2009, at 17:52, Tom Verhoeff wrote: > >> 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. > > http://www.freepa

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

2009-10-19 Thread Jonas Maebe
On 19 Oct 2009, at 14:14, Tom Verhoeff wrote: On Mon, Oct 19, 2009 at 10:21:01AM +0200, Jonas Maebe wrote: http://www.freepascal.org/docs-html/rtl/math/setexceptionmask.html Fully cross-platform, even. How new is that? Not very. I think it exists at least since 2.0.0. It works 'part

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

2009-10-19 Thread Jonas Maebe
On 19 Oct 2009, at 14:36, Jonas Maebe wrote: In case it's Mac OS X on x86: floating point exception reporting via Unix signals isn't exactly its forte. And in case Mac OS X on ppc: the same caveats apply as for x86, except that we don't have to any opcode decoding since the PPC doesn't rai

Re: [fpc-pascal] Who said Pascal isn't popular

2009-10-19 Thread Jeff Wormsley
Graeme Geldenhuys wrote: Any programmer worth hiring should find it relatively easy to switch to another language. Or and least become proficient in it in a relative short period of time. The basic principles apply to all languages, it's just the tool-chain and syntax that differs. I certain

[fpc-pascal] Streaming classes?

2009-10-19 Thread James Buren
I've encountered this mentioned several times in the documentation but I have no clue what its used for or why I would want to use it. Is it talking about reading and writing class information to file, memory, network streams? If not, then what is this?

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

2009-10-19 Thread Bart
Jonas, Could you comment on my opinion that in case of a floating point divide by zero error an EZeroDivide should be raised (or no exception at all depending on the FPU exception mask) and only in case of integer divide by zero (div operation) an EDivByZero should be raised? This was my original

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

2009-10-19 Thread Jonas Maebe
On 19 Oct 2009, at 17:04, Bart wrote: Could you comment on my opinion that in case of a floating point divide by zero error an EZeroDivide should be raised (or no exception at all depending on the FPU exception mask) and only in case of integer divide by zero (div operation) an EDivByZero shoul

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

2009-10-19 Thread Bart
Jonas, I might be just babbling, since I really have no idea how it's done, but: In the code that "translates" the "you did something nasty" to runerror(some_exit_code) it may be possible to differentiate between float and integer fault? This info could then be stored in some variable/object that

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

2009-10-19 Thread Gustavo Enrique Jimenez
2009/10/18 Tom Verhoeff : > 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 va

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

2009-10-19 Thread Frank Peelo
Gustavo Enrique Jimenez wrote: 2009/10/18 Tom Verhoeff : 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 o