Pascal lets you define several types of numeric constants, as well as character and string constants. Every constant has a Pascal data type. These data types will be mentioned in the descriptions that follow, and explained in Chapter 3.


Integer constants may be decimal or hexadecimal. Decimal constants are written as ordinary integers with no decimal point. Leading plus or minus signs are permitted, as are leading zeros. Valid examples of decimal integer constants are

0    12    -45    078    +99

Hexadecimal constants are written with a leading dollar sign ($) in front of them, and may contain the digits 0-9 and the letters A-F. Valid examples of hexadecimal integer constants are

$0    $C   $FE27   $21   $FF

An integer constant has the integer type.

Real Constants

Real constants contain a decimal point, an exponent, or both. If the constant has a decimal point, there must be at least one digit before it and after it; therefore 0.1 is valid but .1 and 1. are not.

Exponents for real constants consist of an upper or lower case E followed by a (possibly signed) integer. The exponential part always comes at the end of the real constant.

Leading plus or minus signs are permitted, as are leading zeros. Valid examples of real constants are

0.0    -12.0    3E4    4e+5    +12.3e-45

A real constant has the real type.

Character Constants

An character constant consists of a single character enclosed in single quotes. Control characters can be placed in character constants by a # character followed by an integer constant (decimal or hexadecimal) corresponding to the desired ASCII value.. Valid examples of character constants are

'a'    '1'    ';'    '#10'    '#$1A'

If you want a character constant that consists of a single quote character, you must type two single quotes enclosed by single quotes:


A character constant has the char type.

String Constants

A string constant consists of zero or more characters enclosed in double quotes, as in

"ab"    "Hello!"    "A line..."    ""

If the string is two or more characters, it can be enclosed in single quotes instead of double quotes:

'ab'   is the same as   "ab"

If there is only one character in the string and you enclose it in single quotes, it will be taken as a character constant rather than a string constant. This causes no problems because Alice lets you use a character constant as a string of length 1. If there are no characters in the string, you cannot use single quotes because '' would be taken as an escape sequence for a single quote.

A string constant has the type packed array of char. Therefore there is a great difference between

'a'  -- character constant, type char
"a"  -- string constant, type packed array of char

Predefined Constants

In addition to normal constants, Alice Pascal has several symbols that are known as predefined constants. Alice assigns constant values to these symbols whenever your program starts executing.


This gives the version number of the Alice you are using.


This has the value of the largest integer that can be represented by the hardware. On the IBM PC, this is 32767.


This is the closest approximation of ``pi'' that your computer can represent (3.14159...).


This has the Boolean value ``true''. For more information about Boolean data, see Chapter 3.


This has the Boolean value ``false''.


This is a special character used to mark the end of strings. It is actually the ASCII null character. StrEnd will be discussed in greater detail in Chapter 3.

You can change the meanings of these predefined names if you choose, but this is not recommended.