Difference between revisions of "Constant"

From Lazarus wiki
Jump to navigationJump to search
(New page: A '''constant''' is something that does not change, a fixed value. Constants are defined in the const section of the program. When some value are constant the [[Compiler|compile...)
 
(→‎See also: Add link to Class Constants)
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
A '''constant''' is something that does not change, a fixed value.
+
{{Constant}}
  
Constants are defined in the [[Const|const]] section of the program. When some value are constant the [[Compiler|compiler]] can do some optimizations.
+
A '''constant''' is a [[Variable|variable]] that does not change, it has a final value.
  
+
Constants are defined in the [[Const#Const_Section|<code>const</code> section]] of a [[FPC|Free Pascal]] [[Program|program]]. When a symbol is defined as constant, the [[Compiler|Free Pascal compiler]] can often do some optimizations to make the output code faster or smaller.
  
 
  
Some special constant values are e.g.
+
Some special Free Pascal constants are:
  
- Logical truth values
+
Logical truth values
 +
* [[False|<syntaxhighlight lang="pascal" enclose="none">false</syntaxhighlight>]]
 +
* [[True|<syntaxhighlight lang="pascal" enclose="none">true</syntaxhighlight>]]
  
* [[False]]
+
data type limits
 +
* [[Nil|<syntaxhighlight lang="pascal" enclose="none">nil</syntaxhighlight>]]: empty [[Pointer|pointer]] value
 +
* [[maxint|<syntaxhighlight lang="pascal" enclose="none">maxint</syntaxhighlight>]]: largest possible [[Integer|<syntaxhighlight lang="pascal" enclose="none">integer</syntaxhighlight>]] value
  
* [[True]]
 
  
- Empty pointer value
+
The mathematical value [[Pi|π]] is realized as a function in {{Doc|package=RTL|unit=system|identifier=pi|text=<syntaxhighlight lang="pascal" enclose="none">system.pi</syntaxhighlight>}}.
  
* [[Nil]]
+
== See also ==
 
+
* [[Const|<syntaxhighlight lang="pascal" enclose="none">const</syntaxhighlight>]]
- Mathematical constants
+
* [[Constants]]
 
+
* [[Class constants]]
* [[Pi]]
 

Revision as of 08:15, 9 August 2020

English (en) suomi (fi) français (fr) русский (ru) 中文(中国大陆)‎ (zh_CN)

A constant is a variable that does not change, it has a final value.

Constants are defined in the const section of a Free Pascal program. When a symbol is defined as constant, the Free Pascal compiler can often do some optimizations to make the output code faster or smaller.


Some special Free Pascal constants are:

Logical truth values

data type limits


The mathematical value π is realized as a function in system.pi.

See also