Difference between revisions of "NaN"

From Lazarus wiki
Jump to navigationJump to search
(Created page with "{{NaN}} NaN (not a number) is a numeric data type value representing an undefined or unrepresentable value. These values result from operations which have undefined numerical...")
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{NaN}}
 
{{NaN}}
  
NaN (not a number) is a numeric data type value representing an undefined or unrepresentable value.
+
<syntaxhighlight lang="pascal" inline>NaN</syntaxhighlight> (not a number) is a numeric data type value representing an undefined or unrepresentable value.
 
These values result from operations which have undefined numerical results.
 
These values result from operations which have undefined numerical results.
NaN is not the same as infinity.
+
<syntaxhighlight lang="pascal" inline>NaN</syntaxhighlight> is not the same as infinity.
 
 
<source>
 
program Project1;
 
  
 +
<syntaxhighlight lang="pascal" line highlight="3-4">
 +
program NotANumber(input, output, stderr);
 
begin
 
begin
  Writeln (0/0);
+
// writes 'Nan' (with spacing) on its own line
  Readln;
+
writeLn(0/0);
 
end.
 
end.
</source>
+
</syntaxhighlight>
 +
 
 +
Note, <syntaxhighlight lang="pascal" inline>NaN</syntaxhighlight> exists only in the context of floating point number calculations:
 +
<syntaxhighlight lang="pascal" inline>0 div 0</syntaxhighlight> ([[Div|integer division]]) is not allowed, though.
 +
 
 +
== See also ==
 +
* {{Doc|package=RTL|unit=math|identifier=nan|text=Value “is not a number”}}
 +
* {{Doc|package=RTL|unit=math|identifier=isnan|text=<code>IsNan</code>}} checks whether value is “not a number”.
 +
* [[TAChart documentation#Skipping source items|<code>TAChart</code> documentation, § “skipping source items”]]

Latest revision as of 17:16, 6 August 2022

English (en) suomi (fi) русский (ru)

NaN (not a number) is a numeric data type value representing an undefined or unrepresentable value. These values result from operations which have undefined numerical results. NaN is not the same as infinity.

1program NotANumber(input, output, stderr);
2begin
3	// writes 'Nan' (with spacing) on its own line
4	writeLn(0/0);
5end.

Note, NaN exists only in the context of floating point number calculations: 0 div 0 (integer division) is not allowed, though.

See also