RAD Studio
ContentsIndex
PreviousUpNext
Constants

Constants are tokens representing fixed numeric or character values.  

The compiler supports four classes of constants: integer, floating point, character (including strings), and enumeration.  

Internal representation of numerical types shows how these types are represented internally. 

The data type of a constant is deduced by the compiler using such clues as numeric value and the format used in the source code. The formal definition of a constant is shown in the following table.  

Constants: Formal Definitions  

constant:
floating-constant
integer-constant
numeration-constant
character-constant  
nonzero-digit: one of
1 2 3 4 5 6 7 8 9  
floating-constant:
fractional-constant <exponent-part> <floating-suffix>
digit-sequence exponent-part <floating-suffix>  
octal-digit: one of
0 1 2 3 4 5 6 7  
fractional-constant:
<digit-sequence> . digit-sequence
digit-sequence . a b c d e f  
hexadecimal-digit: one of
0 1 2 3 4 5 6 7 8 9
A B C D E F  
exponent-part:
e <sign> digit-sequence
E <sign> digit-sequence  
integer-suffix:
unsigned-suffix <long-suffix>
long-suffix <unsigned-suffix>  
sign: one of
  • -
 
unsigned-suffix: one of
u U  
digit-sequence:
digit
digit-sequence digit  
long-suffix: one of
l L  
floating-suffix: one of
f l F L  
enumeration-constant:
identifier  
integer-constant:
decimal-constant <integer-suffix>
octal-constant <integer-suffix>
hexadecimal-constant <integer-suffix>  
character-constant
c-char-sequence  
decimal-constant:
nonzero-digit
decimal-constant digit  
c-char-sequence:
c-char
c-char-sequence c-char  
octal-constant:
0
octal-constant octal-digit  
c-char:
Any character in the source character set
except the single-quote ('), backslash (\), or
newline character escape-sequence.  
hexadecimal-constant:
0 x hexadecimal-digit
0 X hexadecimal-digi
hexadecimal-constant hexadecimal-digit  
escape-sequence: one of the following
\" \' \? \\
t \a \b \f \n
\o \oo \ooo \r
\t \v \Xh... \xh...  
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!