Numeric Conversion Functions [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation
HP Pascal/iX Reference Manual
Numeric Conversion Functions
binary, hex, and octal are the three numeric conversion functions
supported in HP Pascal.
binary, hex, and octal return an integer value. Therefore, all bits must
be specified if a negative result is desired. Alternatively, the
positive representation may be negated.
A description of each of these functions follows.
binary
Usage
binary(s)
Argument
s Any string or PAC expression whose range is implementation
dependent.
Description
The binary function converts a string or PAC expression that is
interpreted as a binary value to an integer. Leading and trailing blanks
are ignored in the argument. It is an error if any character is not a
legal binary digit; for example, 0..1.
Example
Input Result
binary(strng) depends on the value of strng
binary('10011') 19
-binary('10011') -19
NOTE If your particular implementation uses 32-bit 2's complement
notation, the following example also works:
binary('11111111111111111111111111101101') = -19
hex
Usage
hex(s)
Argument
s Any string or PAC expression whose range is implementation
dependent.
Description
The hex function converts a string or PAC expression, that is interpreted
as a hexadecimal value to an integer. Leading and trailing blanks are
ignored. It is an error if any character is not a legal hex digit; for
example, 0..9, 'A'..'F', or 'a'..'f'.
Example
Input Result
hex(strng) depends on the value of strng
hex('FF') 255
-hex('FF') -255
NOTE If a particular implementation uses 32-bit 2's complement notation,
the following example also works:
hex('FFFFFF01') = -255
octal
Usage
octal(s)
Argument
s Any string or PAC expression whose range is implementation
dependent.
Description
The octal function converts a string or PAC expression that is
interpreted as an octal value to an integer. Leading and trailing blanks
in the argument are ignored. It is an error if any other character is
not a legal octal digit; for example, 0..7.
Example
Input Result
octal(strng) depends on the value of strng
octal('77') 63
-octal('77') -63
NOTE If your particular implementation uses 32-bit 2's complement
notation, the following example also works:
octal('37777777701') -63
MPE/iX 5.0 Documentation