[fpc-pascal] NAN for double

Daniël Mantione daniel.mantione at freepascal.org
Thu Jan 25 13:20:37 CET 2007



Op Thu, 25 Jan 2007, schreef Mattias Gaertner:

> On Thu, 25 Jan 2007 12:10:44 +0100 (CET)
> Daniël Mantione <daniel.mantione at freepascal.org> wrote:
> 
> > 
> > 
> > Op Thu, 25 Jan 2007, schreef Mattias Gaertner:
> > 
> > > 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

Well, not here. See the program below. Can you check if this depends on 
the compiler version or mode? 0/0 should normally work.

Daniël


daniel at idefix:~> cat nan.pas
program nan;

const _nan=0/0;

begin
  writeln(_nan);
end.
daniel at idefix:~> ppc386 nan
Free Pascal Compiler version 2.0.4 [2006/08/20] for i386
Copyright (c) 1993-2006 by Florian Klaempfl
Target OS: Linux for i386
Compiling nan.pas
Linking nan
7 Lines compiled, 0.0 sec
daniel at idefix:~> ./nan
                      Nan
daniel at idefix:~>


More information about the fpc-pascal mailing list