True Constants

A true constant is a declared identifier whose value cannot change. For example, const MaxValue = 237;

declares a constant called MaxValue that returns the integer 237. The syntax for declaring a true constant is const identifier = constantExpression where identifier is any valid identifier and constantExpression is an expression that the compiler can evaluate without executing your program.

If constantExpression returns an ordinal value, you can specify the type of the declared constant using a value typecast. For example const MyNumber = Int64(17);

declares a constant called MyNumber, of type Int64, that returns the integer 17. Otherwise, the type of the declared constant is the type of the constantExpression.

  • If constantExpression is a character string, the declared constant is compatible with any string type. If the character string is of length 1, it is also compatible with any character type.
  • If constantExpression is a real, its type is Extended. If it is an integer, its type is given by the table below.
Types for integer constants

Range of constant(hexadecimal)

Range of constant(decimal)

Type

-$8000000000000000..-$80000001

-2A63..-2147483649

Int64

-$80000000..-$8001

-2147483648..-32769

Integer

-$8000..-$81

-32768..-129

Smallint

-$80..-1 -128..-1 Shortint

0..$7F

0..127

0..127

$80..$FF

128..255

Byte

$0100..$7FFF

256..32767

0..32767

$8000..$FFFF

32768..65535

Word

$10000..$7FFFFFFF

65536..2147483647

0..2147483647

$80000000..$FFFFFFFF

2147483648..4294967295

Cardinal

$100000000..$7FFFFFFFFFFFFFFF 4294967296..2A631

Int64

Here are some examples of constant declarations:

const

Ln10 = 2.302585092994045684;

AlphaNum = Alpha + Numeric;

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment