Difference between revisions of "NaN"

From Lazarus wiki
Jump to navigationJump to search
(formatting; add note only for floating point numbers; http_s_ links to documentation)
Line 1: Line 1:
 
{{NaN}}
 
{{NaN}}
  
NaN (not a number) is a numeric data type value representing an undefined or unrepresentable value.
+
<code>NaN</code> (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.
+
<code>NaN</code> is not the same as infinity.
 
 
<source>
 
program Project1;
 
  
 +
<syntaxhighlight>
 +
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, <code>NaN</code> exists only in the context of floating point number calculations:
 +
<code>0 div 0</code> (integer division) is not allowed, though.
  
 
== See also ==
 
== See also ==
* [[doc:rtl/math/nan.html| Value is Not a Number]] (fpc doc)
+
* {{Doc|package=RTL|unit=math|identifier=nan|text=Value “is not a number”}}
* [[doc:rtl/math/isnan.html|IsNan]] check whether 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]]
+
* [[TAChart documentation#Skipping source items|<code>TAChart</code> documentation, § “skipping source items”]]

Revision as of 02:41, 29 January 2018

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.

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

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

See also