# Constants in delphi

In delphi, there are two kinds of constants: regular and named.

A regular constant is an integer or fractional number, a string of characters or a single character, a Boolean value.

### Numeric constants

In the text of the program, numerical constants are written in the usual way, that is, in the same way as numbers, for example, when solving mathematical problems. When writing fractional numbers, a period is used to separate the integer and fractional parts. If the constant is negative, a minus sign is placed immediately before the first digit.

The following are examples of numeric constants:

123 0.0 -524.03 0

Fractional constants can be represented as a floating-point number. The floating-point representation is based on the fact that any number can be written in algebraic form as the product of a number less than 10, which is called a mantissa, and a power of ten, called an order.

In Table. 1.3 are examples of numbers written in ordinary form, in algebraic form, and in floating-point form.

**Table 1.3**. Examples of writing fractional numbers.

Number | Algebraic form | Floating-point form |
---|---|---|

1 000 000 | 1x10^{6} | 1.0000000000e+06 |

-123.452 | -1.23452x10^{2} | -1.2345200000e+02 |

0.0056712 | 5.6712x10-3 | 5.6712000000e-03 |

### String and character constants

String and character constants are enclosed in quotation marks. The following are examples of string constants:

'Delphi programming language' 'Delphi 7'

'2.4'

'D'

Here you should pay attention to the constant '2.4'. It is a symbolic constant, i.e. a string of characters that represents the number "two integers four tenths" rather than the number 2.4.

### Logical constants

A logical statement (expression) can be either true or false. The truth corresponds to the constant **True**, the value "false" corresponds to the constant **False**.

### Named constant

**A named constant is a** name (identifier) that a program uses instead of the constant itself.

A named constant, like a variable, must be declared before it can be used. In general, the statement for declaring a named constant is as follows:

`constant = value; `

Where is:

**constant – the**name of the constant;**value**—The value of the constant.

Named constants are declared in the program in the constant declaration section, which begins with the word **const**. The following is an example of declaring named constants (integer, string, and fractional).

const

Bound = 10;

Title = 'Running speed';

pi = 3.1415926;

After you declare a named constant in your program, you can use the name of the constant instead of the constant itself.

Unlike a variable, when declaring a constant, the type is not explicitly specified. The type of constant is determined by its appearance, for example:

- 125 is a constant of integer type;
- 0.0 – constant of real type;
- ' execute ' – string constant;
- ' \' is a symbolic constant.