[fpc-pascal] math with infinity and NaN
gtt at wolfgang-ehrhardt.de
gtt at wolfgang-ehrhardt.de
Wed Jun 20 09:42:02 CEST 2018
This is compatible with IEEE-754. Section 7.2 says
<quote>
7.2 Invalid operation
For operations producing results in floating-point format, the default
result of an operation that signals the
invalid operation exception shall be a quiet NaN that should provide
some diagnostic information (see 6.2).
These operations are:
...
b) multiplication: multiplication(0, ∞) or multiplication(∞, 0)
...
d) addition or subtraction or fusedMultiplyAdd: magnitude subtraction
of infinities, such as:
addition(+∞, −∞)
e) division: division(0, 0) or division(∞, ∞)
...
g) squareRoot if the operand is less than zero
</quote>
You get the expected quite NaN results if you add the line
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,
exOverflow, exUnderflow, exPrecision]);
to your test programs.
More information about the fpc-pascal
mailing list