[fpc-pascal] math with infinity and NaN

James Richters james at productionautomation.net
Thu Jun 21 21:27:01 CEST 2018


The fact that it raises the exception at all makes it a signaling NaN not a quiet Nan, but they are supposed to be Quiet Nan which never throw the exception according to the specification which clearly states they are Quiet Nans, not Signaling Nans.   Suppressing the exception makes them act like quiet nans, but the fact that they need suppressing of the exception makes them signaling nans.

-----Original Message-----
From: fpc-pascal [mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of gtt at wolfgang-ehrhardt.de
Sent: Thursday, June 21, 2018 9:32 AM
To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
Subject: Re: [fpc-pascal] math with infinity and NaN


Zitat von James Richters <james at productionautomation.net>:

>> 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).
>
> If it shall be a quiet NaN doesn't that mean it would never cause  
> the runtime error?   To my understating signaling NaN raises the  
> exception, and Quiet Nan does not.. it just quietly sets the variable 
> to NaN and continues by default.
> It states that the DEFAULT result shall be this quiet NaN so if that's 
> the case then setting SetExceptionMask([exInvalidOp]); should not be 
> required to prevent the runtime error.  The default behavior should be 
> that it's a Quiet NaN.

As far as I understand: if the exInvalidOp is masked the default result is a quiet NaN. If exInvalidOp is not masked the excption is thrown.
(I do not know if a result is set to NaN and how this could be exploited).

_______________________________________________
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