Difference between revisions of "Constant"

From Free Pascal wiki
Jump to navigationJump to search
(edit)
m (bypass redirect)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{Constant}}
 
{{Constant}}
  
A '''constant''' is a variable that does not change, it has a fixed value.
+
A '''constant''' is a [[Variable|variable]] that does not change, it has a final value.
  
Constants are defined in the [[Const#Const_Section|const]] section of a Free Pascal program. When a variable is constant the [[Compiler|Free Pascal compiler]] can often do some optimizations to make the output code faster or smaller.
+
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 Free Pascal constants:
+
 
 +
Some special Free Pascal constants are:
  
 
Logical truth values
 
Logical truth values
* [[False]]
+
* [[False|<syntaxhighlight lang="pascal" inline>false</syntaxhighlight>]]
* [[True]]
+
* [[True|<syntaxhighlight lang="pascal" inline>true</syntaxhighlight>]]
  
Empty pointer value
+
data type limits
* [[Nil]]
+
* [[Nil|<syntaxhighlight lang="pascal" inline>nil</syntaxhighlight>]]: empty [[Pointer|pointer]] value
 +
* [[maxint|<syntaxhighlight lang="pascal" inline>maxint</syntaxhighlight>]]: largest possible [[Integer|<syntaxhighlight lang="pascal" inline>integer</syntaxhighlight>]] value
  
Mathematical values
 
* [[Pi]]
 
  
== read more ==
+
The mathematical value [[Pi|π]] is realized as a function in {{Doc|package=RTL|unit=system|identifier=pi|text=<syntaxhighlight lang="pascal" inline>system.pi</syntaxhighlight>}}.
* [[Const]]
 
* [[Constants]]
 
  
[[Category:Constants]]
+
== See also ==
[[Category:Pascal]]
+
* [[Const|<syntaxhighlight lang="pascal" inline>const</syntaxhighlight>]]
 +
* [[Basic Pascal Tutorial/Chapter 1/Constants|Constants]]
 +
* [[Class constants]]

Latest revision as of 21:53, 23 February 2023

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