Functions and Procedures
Table 1-2 through Table 1-11 summarize the functions and procedures in
the Compiler Library. Chapter 2 describes mathematical functions.
Chapter 3 describes the utility procedures. Chapter 4 describes the
packed-decimal procedures. Appendix A describes an error message
handling routine and the Compiler Library/XL error messages.
Table 1-2. Absolute Value Functions
---------------------------------------------------------------------------------------------
| | |
| Function | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| CABS or CABS' | Calculates the absolute value of a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DABS or DABS' | Calculates the absolute value of a longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DSIGN or DSIGN' | Calculates the absolute value of one longreal number and |
| | gives it the sign of a second longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| ISIGN or ISIGN' | Calculates the absolute value of a shortint number and |
| | gives it the sign of a second shortint number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| JSIGN or JSIGN' | Calculates the absolute value of one integer number and |
| | gives it the sign of a second integer number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| SIGN or SIGN' | Calculates the absolute value of one real number and |
| | gives it the sign of a second real number. |
| | |
---------------------------------------------------------------------------------------------
Table 1-3. Number Conversion Functions
---------------------------------------------------------------------------------------------
| | |
| Function | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| AINT or AINT' | Truncates a real number to an integer number in real |
| | representation. |
| | |
---------------------------------------------------------------------------------------------
| | |
| AMOD or AMOD' | Calculates a real number modulus a second real number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DDINT or DDINT' | Truncates a longreal number to an integer number in |
| | longreal representation. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DFIX or DFIX' | Truncates a longreal number to an integer number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DFLOAT or DFLOAT' | Converts an integer number to a longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DMOD | Calculates a longreal number modulus a second longreal |
| | number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| IFIX or IFIX' | Truncates a real number to a shortint number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| INT or INT' | Truncates a real number to a shortint number. |
| | |
---------------------------------------------------------------------------------------------
Table 1-4. Exponent, Root, and Logarithm Functions
---------------------------------------------------------------------------------------------
| | |
| Function | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| ALOG or ALOG' | Calculates the natural logarithm of a positive real number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| ALOG10 | Calculates the base 10 logarithm of a positive real number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| CEXP or CEXP' | Calculates ex , where x is a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| CLOG or CLOG' | Calculates the natural logarithm of a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| CSQRT or CSQRT' | Calculates the square root of a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DEXP or DEXP' | Calculates ex , where x is a longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DLOG or DLOG' | Calculates the natural logarithm of a positive longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DLOG10 | Calculates the base 10 logarithm of a positive longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DSQRT or DSQRT' | Calculates the square root of a longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| EXP or EXP' | Calculates ex , where x is a real number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| SQRT or SQRT' | Calculates the square root of a real number. |
| | |
---------------------------------------------------------------------------------------------
Table 1-5. Trigonometry Functions
---------------------------------------------------------------------------------------------
| | |
| Function | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| ATAN or ATAN' | Calculates the arctangent of a real number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| ATAN2 or ATAN2' | Calculates the arctangent of the quotient of two real |
| | numbers. |
| | |
---------------------------------------------------------------------------------------------
| | |
| CCOS or CCOS' | Calculates the cosine of a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| CCOSH or CCOSH' | Calculates the hyperbolic cosine of a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| COS or COS' | Calculates the cosine of a real number in radians. |
| | |
---------------------------------------------------------------------------------------------
| | |
| COSH or COSH' | Calculates the hyperbolic cosine of a real number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| CSIN or CSIN' | Calculates the sine of a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| CSINH or CSINH' | Calculates the hyperbolic sine of a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| CTAN or CTAN' | Calculates the tangent of a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| CTANH or CTANH' | Calculates the hyperbolic tangent of a complex number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DATAN or DATAN' | Calculates the arctangent of a longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DATAN2 | Calculates the arctangent of the quotient of two |
| | longreal numbers. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DCOS or DCOS' | Calculates the cosine of a longreal number in radians. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DCOSH or DCOSH' | Calculates the hyperbolic cosine of a longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DSIN or DSIN' | Calculates the sine of a longreal number in radians. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DSINH or DSINH' | Calculates the hyperbolic sine of a longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DTAN or DTAN' | Calculates the tangent of a longreal number in radians. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DTANH or DTANH' | Calculates the hyperbolic tangent of a longreal number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| SIN or SIN' | Calculates the sine of a real number in radians. |
| | |
---------------------------------------------------------------------------------------------
| | |
| SINH or SINH' | Calculates the hyperbolic tangent of a real number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| TAN or TAN' | Calculates the tangent of a real number in radians. |
| | |
---------------------------------------------------------------------------------------------
| | |
| TANH or TANH' | Calculates the hyperbolic tangent of a real number. |
| | |
---------------------------------------------------------------------------------------------
Table 1-6. Matrix Functions
---------------------------------------------------------------------------------------------
| | |
| Function | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| CINVERT | Inverts a square matrix of complex numbers. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DINVERT | Inverts a square matrix of longreal numbers. |
| | |
---------------------------------------------------------------------------------------------
| | |
| INVERT | Inverts a square matrix of real numbers. |
| | |
---------------------------------------------------------------------------------------------
Table 1-7. Random Number Functions
---------------------------------------------------------------------------------------------
| | |
| Function | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| RAND or RAND' | Generates the next element of a sequence of |
| | pseudo-random numbers. |
| | |
---------------------------------------------------------------------------------------------
| | |
| RAND1 or RAND1' | Generates a random number for use as a |
| | starting point for RAND. |
| | |
---------------------------------------------------------------------------------------------
Table 1-8. Integer Arithmetic Functions
---------------------------------------------------------------------------------------------
| | |
| Function | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| DADD | Calculates the sum of two integer numbers. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DCMP | Compares two integer numbers. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DDIV or DDIV' | Calculates the quotient of one integer number divided by |
| | another integer number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DMPY or DMPY' | Calculates the product of two integer numbers. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DNEG | Negates an integer number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DREM or DREM' | Calculates the remainder of one integer number divided |
| | by another integer number. |
| | |
---------------------------------------------------------------------------------------------
| | |
| DSUB | Calculates the difference between two integer numbers. |
| | |
---------------------------------------------------------------------------------------------
Table 1-9. Intrinsic Function
---------------------------------------------------------------------------------------------
| | |
| Function | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| XLIBTRAP | Specifies a user-defined function to process library |
| | errors. |
| | |
---------------------------------------------------------------------------------------------
Table 1-10. Utility Procedures
---------------------------------------------------------------------------------------------
| | |
| Procedure | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| EXTIN' or HPEXTIN | Converts a byte array of ASCII numeric data to an |
| | internal representation. |
| | |
---------------------------------------------------------------------------------------------
| | |
| INEXT' or HPINEXT | Converts an internal representation of a number to a |
| | byte array for ASCII numeric data. |
| | |
---------------------------------------------------------------------------------------------
Table 1-11. Packed-Decimal Procedures
---------------------------------------------------------------------------------------------
| | |
| Procedure | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACADDD | Adds two packed-decimal numbers. |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACCMPD | Compares two packed-decimal operands and sets a |
| | comparison code. |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACCVAD | Converts from ASCII to packed-decimal |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACCVBD | Converts a binary number to packed-decimal. |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACCVDA | Converts a packed-decimal number to ASCII. |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACCVDB | Converts a packed-decimal number to binary. |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACLONGDIVD or HPPACDIVD | Calculates the quotient, or the quotient and the |
| | remainder, of a packed-decimal dividend and a |
| | packed-decimal divisor. |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACMPYD | Multiplies two packed-decimal numbers |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACNSLD | Performs a packed-decimal normalizing left shift. |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACSLD | Performs a packed-decimal left shift. |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACSRD | Performs a packed-decimal right shift. |
| | |
---------------------------------------------------------------------------------------------
| | |
| HPPACSUBD | Subtracts one packed-decimal number from another. |
| | |
---------------------------------------------------------------------------------------------
You can use the HP Pascal intrinsic statement to declare the compiler
library procedure or function. For HP Pascal, for example, the external
declaration could be declared:
FUNCTION SIN (VAR x:REAL): REAL;EXTERNAL;
or the external declaration could more easily be declared as:
FUNCTION SIN:REAL;INTRINSIC;
You can use the HP FORTRAN 77 system intrinsic statement to declare the
compiler library procedure or function.
For HP FORTRAN 77/XL, for example, the external declaration could be
declared by:
$ALIAS EXTIN = 'EXTIN"' (%REF, %REF, %VAL, %VAL, %VAL, %VAL, %REF, %REF)
or the intrinsic statement could be used:
SYSTEM INTRINSIC HPEXTIN
In HP C/XL, the intrinsic pragma is used to declare an intrinsic. For
example, instead of using the following declaration:
extern void HPPACCVDA( );
you could write:
#pragma intrinsic HPPACCVDA
The function names ending with a prime (EXTIN', for example) can be
called by HP Pascal or HP FORTRAN 77/XL programs using the ALIAS command.
See the HP Pascal Reference Manual or the HP FORTRAN 77/XL Reference
Manual for a detailed description of the ALIAS command. For example,
specify the following statement in your HP Pascal program:
PROCEDURE EXTIN $ALIAS 'EXTIN"'$;INTRINSIC;
Or specify the following statement in your HP FORTRAN 77/XL program:
$ALIAS EXTIN = 'EXTIN"' (%REF, %REF, %VAL, %VAL, %VAL, %VAL, %REF, %REF)