[fpc-pascal] math with infinity and NaN
James Richters
james at productionautomation.net
Wed Jun 20 23:15:47 CEST 2018
Is there a way to prevent getting the runtime error?
James
-----Original Message-----
From: fpc-pascal [mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of Florian Klämpfl
Sent: Wednesday, June 20, 2018 4:59 PM
To: fpc-pascal at lists.freepascal.org
Subject: Re: [fpc-pascal] math with infinity and NaN
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.
_______________________________________________
fpc-pascal maillist - fpc-pascal at lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list