HP 3000 Manuals

Arithmetic Functions [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation


HP Pascal/iX Reference Manual

Arithmetic Functions 

The eight standard arithmetic functions in HP Pascal are abs, arctan,
cos, exp, ln, sin, sqr, and sqrt.  Details about each of these functions
are given in the following pages.

abs 

Usage 

     abs(x) 

Argument 

x          A numeric expression.

Description 

The abs function computes the absolute value of its argument, which must
be an expression with a numeric type.  The type of the result is the same
as the type of the numeric expression.  Note that it may be an error to
take the absolute value of minint.

Example 

     Input                           Result 

     abs(-13)                        13 { integer result }
     abs(-7.11)                      7.110000E+00
     abs (true)                      error { not a numeric type }

arctan 

Usage 

     arctan(x) 

Argument 

x          A numeric expression.

Description 

The arctan function returns the principal value of the angle that has the
tangent equal to the argument.  The result is in radians within the range
-pi/2..pi/2.  This function returns a real for sub-integer, integer, or
real arguments, and longreal for longreal or super-integer arguments.
The value used for pi is implementation dependent. 

Example 

     Input                          Result 

     arctan(num_exp)
     arctan(2)                       1.107149E+00
     arctan(-4.002)                  -1.32594E+00

cos 

Usage 

     cos(x) 

Argument 

x          A numeric expression.

Description 

The cos function returns the cosine of the angle represented by its
argument that is interpreted in radians.  This function returns a real
for sub-integer, integer, or real arguments, and longreal for longreal or
super-integer arguments.  The range of the returned value is -1.0 through
+1.0.

Example 

     Input                           Result 

     cos(x_rad)
     cos(1.62)                       -4.91838E-02

exp 

Usage 

     exp(x) 

Argument 

x          A numeric expression.

Description 

The exp real function raises e to the power of the argument.  This
function returns a real for sub-integer, integer, or real arguments, and
longreal for longreal or super-integer arguments.  The value used for
Naperian e is implementation dependent.

Example 

     Input                           Result 

     exp(3)                          2.008554E+01
     exp(8.8E-3)                     1.008839E+00
     exp(8.8L-3)                     1.00883883382898L+00

ln 

Usage 

     ln(x) 

Argument 

x          Any positive numeric expression.

Description 

The ln function returns the natural logarithm (base e) of the argument.
This function returns a real for sub-integer, integer, or real arguments,
and longreal for longreal or super-integer arguments.  It is an error if
x is 0 or less than 0.  The value used for Naperian e is implementation
dependent.

Example 

     Input                           Result 

     ln(43)                          3.761200E+00
     ln(2.121)                       7.518877E-01
     ln(0)                           { error }

sin 

Usage 

     sin(x) 

Argument 

x          A numeric expression.

Description 

The sin function returns the sine of the angle interpreted in radians
represented by its argument.  This function returns a real for
sub-integer, integer, or real arguments, and longreal for longreal or
super-integer arguments.  Note that the argument can be any numeric
value.

Example 

     Input                           Result 

     sin(rad)
     sin(0.024)                      2.399769E-02
     sin(90)                         8.93997E-01

sqr 

Usage 

     sqr(x) 

Argument 

x          Any numeric expression.

Description 

The sqr function computes the square of its argument that must be an
expression with a numeric type.  The type of the result is the same as
the base type of the numeric expression.

Example 

     Input                           Result 

     sqr(3)                          9
     sqr(1.198E3)                    1.435204E+06.
     sqr(-5)                         25
     sqr(maxint)                     { error }

sqrt 

Usage 

     sqrt(x) 

Argument 

x          Any positive numeric expression.

Description 

The sqrt function computes the square root of its argument, which must be
an expression with a numeric type.  It is an error if the argument is
less than 0.  This function returns a real for sub-integer, integer, or
real arguments, and longreal for longreal or super-integer arguments.

Example 

     Input                           Result 

     sqrt(64)                        8.000000E+00
     sqrt(13.5E12)                   3.674235E+06
     sqrt(0)                         0.000000E+00
     sqrt(-5)                        { error }



MPE/iX 5.0 Documentation