Ingres CL MH
From Ingres Community Wiki
|
Ingres Compatability Library |
Compatibility Library Specification - MH
Abstract
This is the specification of the MH facility provided by the compatibility library.
Revision: 1.3, 11-Nov-1997
Document History
- Revision 1.3, 11-Nov-1997
- Convert to HTML.
- Revision 1.2, 30-Jul-94
- Many of the functions in this module are obsolescent; see FP for better floating point operations, and convert client code where opportune.
- MHi4add, MHi4sub, MHi4mul, MHi4div added (12-mar-93).
- Revision 1.1, last modified 25-Oct-91.
- MHexp10 is deleted; use MHpow instead.
- Revision 1.0, last modified 29-Aug-91.
- Fixed typos.
- INGRES 6.3/01:
- The MH functions MHffinite and MHdfinite (and the include file <clfloat.h>) are new in the 6.3/01 specification, are not referenced by the 6.3/01 mainline code. Conversion to the new scheme is recommended at the earliest opportunity, as the old method was sure to produce bugs on many systems.
- The constants FMIN and FMAX, which were sometimes defined in <mh.h> in the past are now obsolete and illegal. See <clfloat.h> for their replacements.
Specification
Introduction
These routines implement mathematical operations. Many of these routines are used to implement the built in mathematical operations of QUEL.
Header File <mh.h>
The header file <mh.h> must be included before using any of the functions provided. It also defines the following. (Also see <clfloat.h>.)
The following constants are defined in the file <mh.h>.
MH_EXP_10_DIG - decimal digits in an exponent
The number of decimal digits that are needed to format a floating point exponent. On some systems this is 2, where floating point ranges are 1E-37 to 1E+37, and on others it is 3, for 1E-308 to 1E+308.
Systems that support the #if construct might define this symbol as:
# if DBL_MAX_10_EXP > 99 # define MH_EXP_10_DIG 3 # else # define MH_EXP_10_DIG 2 # endif
Executable Interface
The following functions are provided.
MHatan() - arctangent
Find the arctangent of x. Returned result is in radians.
Inputs:
| x | Number to find the arctangent of. |
Outputs:
| None |
Returns:
| Returned result is in radians. |
Exceptions:
| MH_BADARG |
| MH_PRECISION |
| MH_INTERNERR |
Definition:
f8 MHatan(x) f8 x;
MHceil - ceiling
Returns the smallest integer not less than the argument passed to it. The return value, although an integer, is returned as an f8.
Inputs:
| x | Number to find ceiling for. |
Outputs:
| None |
Returns:
| The smallest integer (as an f8) not less than x. |
Exceptions:
| MH_BADARG |
| MH_PRECISION |
| MH_INTERNERR |
Definition:
f8 MHceil(x) f8 x;
MHcos - cosine
Find the cosine of x, where x is in radians.
Inputs:
| x | Number of radians to take cosine of. |
Outputs:
| None |
Returns:
| Cosine of x radians. |
Exceptions:
| MH_BADARG |
| MH_PRECISION |
| MH_INTERNERR |
| MH_MATHERR |
Definition:
f8 MHcos(x) f8 x;
MHdfinite - is double a finite value?
Returns non-zero if the input double floating point number is finite, that is, legal for use. On some machines, it is possible for doubles to obtain bit patterns that may not be used meaningfully in subsequent calculations, such as the IEEE NaN and Infinite values.
This routine may be a macro that always evaluates to TRUE on systems where there is no good way to see if the value is finite.
Inputs:
| d | the double value in question. |
Outputs:
| None |
Returns:
| Non-zero if the value is finite. |
Prototype:
i4 MHdfinite( double d );
MHexp - exponential
Find the exponential of x (i.e., e**x).
Inputs:
| x | Number to find exponential for. |
Outputs:
| None |
Returns:
| The value of exp(x) |
Exceptions:
| MH_BADARG |
| MH_PRECISION |
| MH_INTERNERR |
Definition:
f8 MHexp(x) f8 x;
MHfdint - find integer part of a double
Take the integer part of the passed in double and return it as a double.
Inputs:
| x | The double to take the integer part of. |
Outputs:
| None |
Returns:
| The integer part of x (as an f8). |
Definition:
f8 MHfdint( x ) f8 x;
MHffinite - is float a finite value?
Returns non-zero if the input floating point number is finite, that is legal for use. On some machines, it is possible for floats to obtain bit patterns that may not be used meaningfully in subsequent calculations, such as the IEEE NaN and Infinite values.
This routine may be a macro that always evaluates to TRUE on systems where there is no good way to see if the value is finite.
On non-ANSI C systems, or ANSI systems where this routine is not declared with a prototype and defined in the new style, it is identical to MHdfinite, because of the traditional C widening rules for float arguments.
Inputs:
| f | the value in question. |
Outputs:
| None |
Returns:
| Non-zero if the value is finite. |
Prototype:
i4 MHffinite( float f );
MHi4add -- add two i4s, generating exceptions
Return dv1 + dv2
This routine may be defined as a MACRO on machines where the native arithmetic signals the right exceptions, for example VMS. On other systems, they will need to be C routines that do appropriate range checking and raise the exception.
Operations through this routine disregards the setting of the EXmath state. Exceptions must always be raised.
Input:
| dv1 |
| dv2 |
Output:
| none |
Returns:
| "dv1 + dv2" |
Exceptions:
| EXINTOVF |
Definition:
i4 MHi4add(i4 dv1, i4 dv2)
MHi4div - divide two i4s, generating exceptions
Return dv1 / dv2
This routine may be defined as a MACRO on machines where the native arithmetic signals the right exceptions, for example VMS. On other systems, they will need to be C routines that do appropriate range checking and raise the exception.
Operations through this routine disregards the setting of the EXmath state. Exceptions must always be raised.
Input:
| dv1 |
| dv2 |
Output:
| none |
Returns:
| "dv1 / dv2" |
Exceptions:
| EXINTDIV |
Definition:
i4 MHi4div(i4 dv1, i4 dv2)
MHi4mul - multiply two i4s, generating exceptions
Return dv1 * dv2
This routine may be defined as a MACRO on machines where the native arithmetic signals the right exceptions, for example VMS. On other systems, they will need to be C routines that do appropriate range checking and raise the exception.
Operations through this routine disregards the setting of the EXmath state. Exceptions must always be raised.
Input:
| dv1 |
| dv2 |
Output:
| none |
Returns:
| "dv1 * dv2" |
Exceptions:
| EXINTOVF |
Definition:
i4 MHi4mul(i4 dv1, i4 dv2)
MHi4sub - subtract two i4s, generating exceptions
Return dv1 - dv2
This routine may be defined as a MACRO on machines where the native arithmetic signals the right exceptions, for example VMS. On other systems, they will need to be C routines that do appropriate range checking and raise the exception.
Operations through this routine disregards the setting of the EXmath state. Exceptions must always be raised.
Input:
| dv1 |
| dv2 |
Output:
| none |
Returns:
| "dv1 - dv2" |
Exceptions:
| EXINTOVF |
Definition:
i4 MHi4sub(i4 dv1, i4 dv2)
MHipow - integer power
Find x**i.
Inputs:
| x | Number to raise to a power. |
| i | Integer power to raise it to. |
Outputs:
| None |
Returns:
| The value x**i |
Exceptions:
| MH_BADARG |
| MH_PRECISION |
| MH_INTERNERR |
Definition:
f8 MHipow(x,i) f8 x; i4 i;
MHln - natural logarithm
Find the natural logarithm (ln) of x. x must be greater than zero.
Inputs:
| x | Number to find log of. |
Outputs:
| None |
Returns:
| The value ln(x). |
Exceptions:
| MH_BADARG |
| MH_PRECISION |
| MH_INTERNERR |
Definition:
f8 MHln(x) f8 x;
MHpow - power
Find x**y.
Inputs:
| x | Number to raise to a power. |
| y | Power to raise it to. |
Outputs:
| None |
Returns:
| The value x**y |
Exceptions:
| MH_BADARG |
| MH_PRECISION |
| MH_INTERNERR |
Definition:
f8 MHpow(x,y) f8 x,y;
MHrand - random number
Return the next random number. That is, each time this routine is called it will return the next number in a sequence of pseudo-random numbers.
Inputs:
| None |
Outputs:
| None |
Returns:
| A random number between 0 and 1.0 as an f8. |
Definition:
f8 MHrand()
MHsin - sine
Find the sine of x, where x is in radians.
Inputs:
| x | Number of radians to take sine of. |
Outputs:
| None |
Returns:
| The value of sine of x radians. |
Definition:
f8 MHsin(x) f8 x;
MHsqrt - square root
Find the square root of x. Only works if x is non-negative.
Inputs:
| x | Number to find square root of. |
Outputs:
| None |
Returns:
| The value of square root of x. |
Exceptions:
| MH_BADARG |
| MH_PRECISION |
| MH_INTERNERR |
Definition:
f8 MHsqrt(x) f8 x;
MHsrand - set/seed random number generator
Initialize random number generator to a particular starting point.
Inputs:
| seed | Just any ol' number. |
Outputs:
| None |
Returns:
| OK | if operation succeeded, otherwise system specific error status. |
Definition:
STATUS MHsrand(seed) i4 seed;
|
Ingres Compatability Library |
