Shortint [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
Shortint
The predefined data type shortint is an integer in the range
-32768..32767 that is stored in 16 bits. (In contrast, if you declare a
variable to be in that range, it is stored in 32 bits.) The type
shortint has the following uses:
* If you want to access an external non-Pascal routine that has a
formal parameter of a type whose range is -32768..32767, and uses
16-bits of storage, you can declare a corresponding formal Pascal
parameter of type shortint, and it will be compatible.
* For Pascal/V compatibility.
To determine whether a type T is assignment compatible with the type
shortint, you can treat shortint as a subrange of integer. This means
that you can assign a variable v of type T to a variable sv of type
shortint if:
* The type T is integer or a subrange of integer.
* The value of v is within the range of shortint (-32768..32767).
If the ranges of T and shortint do not overlap, the assignment
sv:=v causes a compile-time error. If the ranges of T and
shortint do overlap, but the value of v is outside the range of
shortint the assignment sv:=v causes a run-time error.
Example
PROGRAM prog;
TYPE
T1 = integer; {overlaps shortint range}
T2 = -10..40000; {overlaps shortint range}
T3 = 40000..50000; {does not overlap shortint range}
VAR
v1 : T1; {sv:=v1 may be legal, depending on value of v1}
v2 : T2; {sv:=v2 may be legal, depending on value of v2}
v3 : T3; {sv:=v3 is never legal}
sv : shortint;
BEGIN
v1 := 10;
sv := v1; {legal assignment}
v1 := 45000;
sv := v1; {causes run-time error}
v2 := 400;
sv := v2; {legal assignment}
v2 := 35000;
sv := v2; {causes run-time error}
v3 := 40000;
sv := v3; {causes compile-time error}
END.
MPE/iX 5.0 Documentation