[fpc-pascal] math with infinity and NaN

Florian Klämpfl florian at freepascal.org
Wed Jun 20 22:58:54 CEST 2018


Am 19.06.2018 um 23:50 schrieb James Richters:
> I’ve been updating my old programs to use the MATH unit in freepascal and while testing things I came across a runtime 
> error 217  Invalid floating point operation.  Here is my test program
> 
> Uses math;
> 
> var
> 
>     variable1:double;
> 
>     variable2:double;
> 
> Begin
> 
> variable1:= Infinity;
> 
> variable2:= -1*Infinity;
> 
> Writeln(variable1,' ',Variable2,' ',Variable1+Variable2);
> 
> End.
> 
> My output is:
> 
> Running "i:\programming\test\testmath.exe "
> 
> An unhandled exception occurred at $004015F6:
> 
> EInvalidOp: Invalid floating point operation
> 
>    $004015F6  main,  line 8 of i:/programming/test/testmath.pas
> 
>                      +Inf                     -Inf
> 
> According to the link here: https://en.wikipedia.org/wiki/NaN
> 
> NaN should be produced:

No. The invalid operation is not masked by default. If you do so, FPC just write Nan.



More information about the fpc-pascal mailing list