Transfer Functions [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation
HP Pascal/iX Reference Manual
Transfer Functions
Round and trunc are the transfer functions found in HP Pascal. These
functions are described on the next two pages.
round
Usage
round(x)
Argument
x Any real or longreal expression.
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
MPE/iX 5.0 Documentation