VMS Help
PASCAL, Data Types, Ordinal
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
The values in an ordinal type have a one-to-one correspondence
with the set of positive integers. The values are ordered so
that each has a unique ordinal value indicating its position in
a list of values of that type.
Compaq Pascal provides the INTEGER, INTEGER64 (not available on
all systems) integer types. Also provided are the INTEGER8,
INTEGER16, and INTEGER32 types, which are used as synonyms for
subranges of the INTEGER type.
The range of integer values consists of positive and negative
integer values and of the value 0. The range boundaries depend
on the architecture of the machine you are using.
The largest possible value of the INTEGER type is represented by
the predeclared constant MAXINT.
The largest possible value of the INTEGER64 type is represented
by the predeclared constant MAXINT64.
1.1 - Standard Int Radix
Extended digit notation allows you to express integer values in
terms of a base number. Compaq Pascal accepts numbers in bases
2 through 36.
Syntax:
[[ + | - ]] base-number#[[']]extended-digit[[']]
The 'base-number' specifies the base of the number.
The 'extended-digit' specifies the notation that is appropriate
for the specified base.
You can use extended-digit notation in the same way you use the
conventional integer notation, with the following exceptions:
o Extended-digit values cannot be used as labels.
o Extended-digit notation for INTEGER objects cannot be used
to express numbers outside the range of 0 to MAXINT. (To
express signed numbers, place the unary plus operator (+) or
the unary minus operator (-) in front of the notation;
setting or clearing the high order bit does not set or clear
the sign bit.)
Compaq Pascal allows the use of spaces and tabs to make the
extended-digit notation easier to read. To use spaces and tabs,
enclose the extended digit in single quotation marks (' '). The
following are integer values in the extended-digit notation:
2#10000011
2#'1000 0011'
32#1J
-16#'7FFF FFFF'
1.2 - Nonstandard Int Radix
Compaq Pascal provides another extended integer convention for
compatibility with previous versions of the language. This
notation specifies an integer in either binary (base 2), octal
(base 8), or hexadecimal (base 16) notation.
Syntax:
b
[[ + | - ]] % o [[']]extended-digit[[']]
x
The 'b', 'o', or 'x' specifies binary, octal, or hexidecimal
notation, respectively.
The 'extended-digit' specifies the notation that is appropriate
for the specified base.
The following are extended integer values in the Compaq Pascal
specific notation:
%b'1000 0011'
%O'7712'
-%x'DEC'
The INTEGER_ADDRESS predefined type is an integer that has the
same underlying bit size as a pointer. On OpenVMS systems,
INTEGER_ADDRESS is equivalent to INTEGER32.
The INTEGER8 predefined type is equivalent to the following:
Syntax:
TYPE INTEGER8=[BYTE]-128..127;{ 16#80..16#7F}
The INTEGER16 predefined type is equivalent to the following:
Syntax:
TYPE INTEGER16=[WORD]-32768..32767;{ 16#8000..16#7FFF }
The INTEGER32 predefined type is equivalent to the following:
Syntax:
TYPE INTEGER32=[LONG]-2147483648..2147483647;{ 16#80000000..16#7FFFFFFF }
The INTEGER64 predefined type is equivalent to the following:
Syntax:
INTEGER64=[QUAD]-9223372036854775808..9223372036854775807;
{ 16#8000000000000000..16#7FFFFFFFFFFFFFFF }
The INTEGER64 predefined type is not available on OpenVMS VAX
systems.
Compaq Pascal provides the UNSIGNED and UNSIGNED64 types (not
available on all systems). Also provided are the UNSIGNED8,
UNSIGNED16, UNSIGNED32, CARDINAL, CARDINAL16, and CARDINAL32
types, which are used as synonyms for the UNSIGNED type. The
range of unsigned values consists of nonnegative integer values.
The largest possible value of the UNSIGNED data type is
represented by the predefined constant MAXUNSIGNED.
The largest value for the UNSIGNED64 data type is represented by
the predefined constant MAXUNSIGNED64.
The smallest possible value for the UNSIGNED data type is 0.
Extended digit notation allows you to express unsigned integer
values in terms of a base number. Compaq Pascal accepts numbers
in bases 2 through 36.
Syntax:
[[ + | - ]] base-number#[[']]extended-digit[[']]
The 'base-number' specifies the base of the number.
The 'extended-digit' specifies the notation that is appropriate
for the specified base.
You can use extended-digit notation in the same way you use the
conventional unsigned integer notation, except that
extended-digit values cannot be used as labels.
Compaq Pascal allows the use of spaces and tabs to make the
extended-digit notation easier to read. To use spaces and tabs,
enclose the extended digit in single quotation marks (' '). The
following are unsigned integer values in the extended-digit
notation:
16#80000000
16#'8000 0000'
16#'FFFF FFFF'
8.1 - Nonstandard Uns Radix
Compaq Pascal provides another extended integer convention only
for the sake of compatibility with previous versions of the
language. This notation specifies an unsigned integer in either
binary (base 2), octal (base 8), or hexadecimal (base 16)
notation.
Syntax:
b
[[ + | - ]] % o [[']]extended-digit[[']]
x
The 'b', 'o', or 'x' specifies binary, octal, or hexidecimal
notation, respectively.
The 'extended-digit' specifies the notation that is appropriate
for the specified base.
The following are unsigned integer values in the Compaq Pascal
specific notation:
%x'8000 0000'
%x'FFFF FFFF'
The UNSIGNED8 data type is equivalent to the following:
Syntax:
TYPE UNSIGNED8 = [BYTE]UINT(0)..UINT(255); {0..16#FF}
The UNSIGNED16 data type is equivalent to the following:
Syntax:
TYPE UNSIGNED16 = [WORD]UINT(0)..UINT(65535); {0..16#FFFF}
The UNSIGNED32 data type is equivalent to the following:
Syntax:
TYPE UNSIGNED32 = [LONG]UINT(0)..UINT(4294967295); {0..16#FFFFFFFF}
The UNSIGNED64 data type is equivalent to the following (OpenVMS
Alpha systems only):
Syntax:
TYPE UNSIGNED64 = [QUAD]UINT(0)..UINT(18446744073709551615);
{0..16#FFFFFFFFFFFFFFFF}
The CHAR data type consists of single character values from the
ASCII character set. The largest possible value of the CHAR
data type is the predefined constant MAXCHAR.
To specify a character constant, enclose a printable ASCII
character in single quotation marks. To specify the
single-quote character, enclose two single quotation marks in
single quotation marks. Each of the following is a valid
character constant:
'A'
'0' {This is character 0, not the integer value 0}
'''' {The apostrophe character}
'?'
You can specify nonprinting characters, such as a
control-character, by writing an empty string followed
immediately by the ordinal value of the character in the ASCII
character set, or by using the CHR function followed by the
ordinal value of the character in the ASCII character set. For
example, both of the following specify the bell control
character:
''(7)
CHR(7)
Boolean values are the result of testing relationships for truth
or validity. The Boolean data type consists of the two
predeclared identifiers FALSE and TRUE. The expression
ORD(FALSE) results in the value 0; ORD(TRUE) returns the integer
1.
An enumerated type is a user-defined ordered set of constant
values specified by identifiers.
Syntax:
({enumerated-identifier},...)
The 'enumerated-identifier' is an identifier of the enumerated
type being defined. Compaq Pascal allows a maximum of 65,535
identifiers in an enumerated type.
The values of an enumerated type begin with the value 0 and
follow a left-to-right order. Subsequent identifiers have a
value one greater than the identifier preceding it.
Example: X : ( Spring, Summer, Fall, Winter )
In this enumerated type, Spring (value 0) and Summer (value 1)
are less than Fall (value 2) because they precede Fall in the
list of constant values. Winter (value 3) is greater than Fall
because it follows Fall.
An identifier in an enumerated type cannot be defined for any
other purpose in the same block.
A subrange type is user-defined and specifies a limited portion
of another ordinal type (called the base type). The subrange
syntax indicates the lower and upper limits of the type.
Syntax:
lower-bound..upper-bound
The 'lower-bound' is a constant expression or a formal
discriminant identifier that establishes the lower limit of the
subrange.
The 'upper-bound' is a constant expression or a formal
discriminant identifier that establishes the upper limit of the
subrange. The value of the upper bound must be greater than or
equal to the value of the lower bound.
The base type can be any enumerated or predefined ordinal type.
The values in the subrange type appear in the same order as they
are in the base type. For instance, the result of the ORD
function applied to a value of a subrange type is the ordinal
value that is associated with the relative position of the value
in the base type, not in the subrange type.
You can use a subrange type anywhere in a program that its base
type is legal. A value of a subrange type is converted to a
value of its base type before it is used in an operation. All
rules that govern the operations performed on an ordinal type
pertain to subranges of that type.
Example: TYPE
Day = ( Mon, Tues, Wed, Thurs, Fri, Sat, Sun );
Weekday = Mon..Fri; {subrange of base type Day}
Digit = '0'..'9'; {subrange of base type CHAR}
Month = 1 .. 31; {subrange of base type INTEGER}
On OpenVMS Alpha systems, you can specify the size of INTEGER
and UNSIGNED subranges to be larger than 32-bits, but less than
or equal to 64-bits. For example:
TYPE $BIT43=[BIT(43)]0..8796093022208;
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.