How to set a double to NAN (not a number)?
I only found a IsNAN in the math unit.
Mattias

Mailing lists / fpc-pascal / 2007-01
10 messages · 4 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
How to set a double to NAN (not a number)?
I only found a IsNAN in the math unit.
Mattias
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;Daniël
unit1.pas(28,10) Error: Division by zeroMattias
Afaik that is delphi mode only. Also check the "typ" unit of numlib (in packages)
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
(note this was never endian checked)
On Thu, 25 Jan 2007 12:10:44 +0100 (CET) unit1.pas(28,10) Error: Division by zero Mattias
Op Thu, 25 Jan 2007, schreef Mattias Gaertner:
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
cat nan.pas
program nan;
const _nan=0/0;
begin
writeln(_nan);
end.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
./nan
Nan
How to set a double to NAN (not a number)? I only found a IsNAN in the math unit. Mattias
How to set a double to NAN (not a number)? I only found a IsNAN in the math unit.
Then you should search more ;) Acutally there is NaN
You are right. Sorry, probably a typo in the search. FPC is great.
Mattias
Op Thu, 25 Jan 2007, schreef Mattias Gaertner: Well, not here. See the program below. Can…
It depends on -Cr.
Mattias