HP Pascal/iX Reference Manual (31502-90022)

9- 30
Description
The round function returns the argument rounded to the nearest integer.
If
x
is positive or zero, then round (
x
) is equivalent to trunc(
x
+ 0.5);
otherwise, round (
x
) is equivalent to trunc(
x
- 0.5). It is an error if
the result is greater than
maxint
or less than
minint
.
Example
Input Result
round(3.1+2.4) 6
round(3.1) 3
round(-6.4) -6
round(-4.6) -5
round(1.5) 2
trunc
Usage
trunc
(x)
Argument
x
Any real or longreal expression.
Description
The trunc function returns the integer part of a real or longreal
expression that is the integral part of its argument. The absolute value
of the result is not greater than the absolute value of
x
. It is an
error if the result is greater than
maxint
or less than
minint
.
Example
Input Result
trunc(real_exp) depends on the value of real_exp
trunc(5.61) 5
trunc(-3.38) -3
trunc(18.999) 18
Ordinal Functions
The
ordinal functions
found in HP Pascal are chr, ord, pred, and succ.
Each of these functions are discussed on the next few pages.
chr
Usage
chr
(x)
Argument
x
An integer expression in the range 0..255.
Description
The chr function converts an integer numeric value into an ASCII
character by returning the character value, if any, whose ordinal number
is equal to the value of its argument. Note that it is an error if the
argument is not within the range 0..255.