[fpc-pascal] NAN for double

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Jan 25 13:05:25 CET 2007


On Thu, 25 Jan 2007 12:51:06 +0100 (CET)
marcov at stack.nl (Marco van de Voort) wrote:

> > > > How to set a double to NAN (not a number)?
> > > > I only found a IsNAN in the math unit.
> > > 
> > > const nan=0/0;
> > 
> > unit1.pas(28,10) Error: Division by zero
> 
> Afaik that is delphi mode only. 

Me delphi mode? Are you kidding?


> Also check the "typ" unit of numlib (in packages)

Thanks.

const
  NANDoubleArray : ARRAY[0..7] OF BYTE = ($FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF);
var
  nan : double absolute NANDoubleArray;

Maybe NAN constants for float types can be added to the Math
unit?

Mattias



More information about the fpc-pascal mailing list