Document revision date: 30 March 2001
[Compaq] [Go to the documentation home page] [How to order documentation] [Help on this site] [How to contact us]
[OpenVMS documentation]

Compaq Portable Mathematics Library


Previous Contents Index


drem - Remainder


Interface

F_TYPE drem (F_TYPE x, F_TYPE y)


Description

drem() returns the remainder r = x-n*y, where n = rint(x/y). Additionally, if |n-x/y|=1/2, then n is even. The remainder is computed exactly, and |r| is less than or equal to |y|/2. The drem() and remainder() functions are aliases of each other.

Exceptions

Exceptional Argument Routine Behavior
x = infinity Invalid argument

Note that rem(x,0) has value 0 and is not an exceptional case.

erf - Error Functions


Interface

F_TYPE erf (F_TYPE x)

F_TYPE erfc (F_TYPE x)


Description

erf() returns the value of the error function. The definition of the erf() function is (2/sqrt(pi)) times the area under the curve exp(-t * t) between 0 and x.

erfc() returns (1.0-erf(x)).

Exceptions

The erfc() function can result in an underflow as x gets large.

exp - Exponential


Interface

F_TYPE exp (F_TYPE x)

F_TYPE expm1 (F_TYPE x)


Description

exp() computes the value of the exponential function, defined as e**x, where e is the constant used as a base for natural logarithms.

expm1() computes exp(x)-1 accurately, even for tiny x.

Exceptions

Exceptional Argument Routine Behavior
x > ln(max_float) Overflow
x < ln(min_float) Underflow

See Also

Appendix A, Critical Floating-Point Values

fabs - Absolute Value


Interface

F_TYPE fabs (F_TYPE x)


Description

fabs() computes the absolute value of x.

Exceptions

None.

finite - Check for Finite Value


Interface

int finite (F_TYPE x)


Description

finite() returns the integer value 1 (true) or 0 (false).

finite(x) = 1 when -infinity < x < +infinity.

finite(x) = 0 when |x| = infinity or x is a NaN.

Exceptions

None.

floor - Floor


Interface

F_TYPE floor (F_TYPE x)


Description

floor() returns the largest floating-point number of integral value less than or equal to x.

Exceptions

None.

fmod - Modulo Remainder


Interface

F_TYPE fmod (F_TYPE x, F_TYPE y)


Description

fmod() computes the floating-point remainder of x modulo y. It returns the remainder r = x-n*y, where n = trunc(x/y). The remainder is computed exactly.

The result has the same sign as x and a magnitude less than the magnitude of y.

Exceptions

Exceptional Argument Routine Behavior
x = infinity Invalid argument

Note that fmod(x,0) has value 0 and is not an exceptional case.

fp_class - Classifies IEEE Floating-Point Values


Interface

int fp_class (F_TYPE x)


Description

These routines determine the class of IEEE floating-point values. They return one of the constants in the file <fp_class.h> and never cause an exception, even for signaling NaNs. These routines implement the recommended function class(x) in the appendix of the IEEE Std 754. The constants in <fp_class.h> refer to the following classes of values:
Constant Class
FP_SNAN Signaling NaN (Not-a-Number)
FP_QNAN Quiet NaN (Not-a-Number)
FP_POS_INF +Infinity
FP_NEG_INF -Infinity
FP_POS_NORM Positive normalized
FP_NEG_NORM Negative normalized
FP_POS_DENORM Positive denormalized
FP_NEG_DENORM Negative denormalized
FP_POS_ZERO +0.0 (positive zero)
FP_NEG_ZERO -0.0 (negative zero)

Exceptions

None.

See Also

ANSI/IEEE Std 754-1985, IEEE Standard for Binary Floating-Point Arithmetic

frexp - Convert to Fraction and Integral Power of 2


Interface

F_TYPE frexp (F_TYPE x, int *n)


Description

frexp() breaks a floating-point number into a normalized fraction and an integral power of 2. It stores the integer in the int object pointed to by the n parameter and returns the fraction part.

Exceptions

None.

hypot - Euclidean Distance


Interface

F_TYPE hypot (F_TYPE x, F_TYPE y)


Description

hypot() computes the length of the hypotenuse of a right triangle, where x and y represent the perpendicular sides of the triangle.

hypot(x,y) is defined as the square root of (x**2 + y**2) and returns the same value as cabs(x,y).

Exceptions

Exceptional Argument Routine Behavior
sqrt(x**2 + y**2) > max_float Overflow

See Also

Appendix A, Critical Floating-Point Values

ilogb - Computes an Unbiased Exponent


Interface

int ilogb (F_TYPE x)


Description

ilogb(x) returns the unbiased exponent of x as an integer, (as if x were normalized >= 1.0 and < 2.0) except:
ilogb(NaN) is INT_MIN
ilogb(inf) is INT_MAX
logb(0) is INT_MIN

There are no errors. The sign of x is ignored.

Exceptions

None.

isnan - Check for NaN Value


Interface

int isnan (F_TYPE x)


Description

isnan() returns 1 (true) if x is NaN (the IEEE floating-point reserved Not-a-Number value) and 0 (false) otherwise.

Exceptions

None.

ldexp - Multiply by an Integral Power of 2


Interface

F_TYPE ldexp (F_TYPE x, int n)


Description

ldexp() multiplies a floating-point number, x, by 2**n.

Exceptions

Exceptional Argument Routine Behavior
|x*(2**n)| > max_float Overflow
|x*(2**n)| < min_float Underflow

See Also

Appendix A, Critical Floating-Point Values

lgamma - Computes the Logarithm of the gamma Function


Interface

F_TYPE lgamma (F_TYPE x)


Description

lgamma() returns the logarithm of the absolute value of gamma of x, or ln(|G(x)|), where G is the gamma function. The sign of gamma of x is returned in the external integer variable signgam as +1 or -1. The x parameter cannot be 0 or a negative integer.

gamma() returns the natural log of the gamma function and so is functionally equivalent to lgamma(). Because of this, gamma() is marked TO BE WITHDRAWN in the X/Open Portability Guide, Revision 4 (XPG4).

Exceptions

Exceptional Argument Routine Behavior
|x| = infinity Invalid argument
x = 0, -1, -2, -3, ... Invalid argument
|x| > lgamma_max_float Overflow

See Also

Appendix A, Critical Floating-Point Values

log - Logarithm Functions


Interface

F_TYPE ln (F_TYPE x)

F_TYPE log2 (F_TYPE x)

F_TYPE log10 (F_TYPE x)

F_TYPE log1p (F_TYPE y)


Description

ln() computes the natural (base e) logarithm of x.

log2() computes the base 2 logarithm of x.

log10() computes the common (base 10) logarithm of x.

log1p() computes ln(1+y) accurately, even for tiny y.

Exceptions

Exceptional Argument Routine Behavior
x < 0 Invalid argument
x = 0 Overflow
1+y < 0 Invalid argument
1+y = 0 Overflow

logb - Radix-independent Exponent


Interface

F_TYPE logb (F_TYPE x)


Description

logb() returns a signed integer converted to double-precision floating-point and so chosen that 1 <= |x|/2**n < 2 unless x = 0 or |x| = infinity.

IEEE Std 754 defines logb(+infinity) = +infinity and logb(0) = -infinity. The latter is required to signal division by zero.

Exceptions

Exceptional Argument Routine Behavior
x = 0 Invalid argument

modf - Return the Fractional Part and Integer Part of a Floating-Point Number


Interface

F_TYPE modf (F_TYPE x, F_TYPE *n)


Description

modf() splits a floating-point number x into a fractional part f and an integer part i such that |f| < 1.0 and (f + i) = x. Both f and i have the same sign as x. modf() returns f and stores i into the location pointed to by n.

Exceptions

None.

nextafter - Next Machine Number After


Interface

F_TYPE nextafter (F_TYPE x, F_TYPE y)


Description

nextafter() returns the machine-representable number next to x in the direction y.

Exceptions

Exceptional Argument Routine Behavior
x = max_float and y = +infinity Overflow
x = -max_float and y = -infinity Overflow
x = min_float and y is less than or equal to 0 Underflow
x = -min_float and y is greater than or equal to 0 Underflow

See Also

ANSI/IEEE Std 754-1985, IEEE Standard for Binary Floating-Point Arithmetic

nint - Round to the Nearest Integer


Interface

F_TYPE nint (F_TYPE x)


Description

nint() returns the nearest integral value to x, except halfway cases are rounded to the integral value larger in magnitude. This function corresponds to the Fortran generic intrinsic function nint().

Exceptions

None.

pow - Raise the Base to a Floating-Point Exponent


Interface

F_TYPE pow (F_TYPE x, F_TYPE y)


Description

pow() raises a floating-point base x to a floating-point exponent y. The value of pow(x,y) is computed as e**(y ln(x)) for positive x. If x is 0 or negative, see your language reference manual.

Passing a NaN input value to pow() produces a NaN result for nonzero values of y. For pow(NaN,0), see your language reference manual.

Exceptions

Exceptional Argument Routine Behavior
y ln(x) > ln(max_float) Overflow
y ln(x) < ln(min_float) Underflow
Fortran-Exceptional Argument Routine Behavior
x < 0 Invalid argument
x = 0 and y < 0 Invalid argument
x = 0 and y = 0 Invalid argument
x = +infinity and y = 0 Invalid argument
x = 1 and |y| = infinity Invalid argument
ANSI C-Exceptional Argument Routine Behavior
|x| = 1 and |y| = infinity Invalid argument
x < 0 and y is not integral Invalid argument

See Also

Appendix A, Critical Floating-Point Values

random - Random Number Generator, Uniformly Distributed


Interface

F_TYPE random (int *n)


Description

random() is a general random number generator. The argument to the random function is an integer passed by reference. There are no restrictions on the input argument, although it should be initialized to different values on separate runs in order to obtain different random sequences. This function must be called again to obtain the next pseudo random number. The argument is updated automatically.

The result is a floating-point number that is uniformly distributed in the interval (0.0,1.0).

Exceptions

None.

remainder - Remainder


Interface

F_TYPE remainder (F_TYPE x, F_TYPE y)


Description

remainder() returns the remainder r = x-n*y, where n = rint(x/y). Additionally, if |n-x/y| = 1/2, then n is even. Consequently, the remainder is computed exactly, and |r| is less than or equal to |y|/2. The drem() and remainder() functions are aliases of each other.

Exceptions

Exceptional Argument Routine Behavior
x = infinity Invalid argument

Note that rem(x,0) has value 0 and is not an exceptional case.

rint - Return the Nearest Integral Value


Interface

F_TYPE rint (F_TYPE x)


Description

rint() rounds x to an integral value according to the current IEEE rounding direction specified by the user.

Exceptions

None.

scalb - Exponent Adjustment


Interface

F_TYPE scalb (F_TYPE x, F_TYPE y)


Description

scalb() = x*(2**y) computed, for integer-valued floating point number y.

Exceptions

Exceptional Argument Routine Behavior
x*(2**y) > max_float Overflow
x*(2**y) < min_float Underflow
x=0, y=infinity Invalid argument
x=infinity, y=-infinity Invalid argument

See Also

Appendix A, Critical Floating-Point Values

sin - Sine of Angle


Interface

F_TYPE sin (F_TYPE x)

F_TYPE sind (F_TYPE x)


Description

sin() computes the sine of x, measured in radians.

sind() computes the sine of x, measured in degrees.

Exceptions

Exceptional Argument Routine Behavior
|x| = infinity Invalid argument
(sind) |x| < (180/pi) * min_float Underflow

See Also

Appendix A, Critical Floating-Point Values

sincos - Sine and Cosine of Angle


Interface

F_COMPLEX sincos (F_TYPE x)

F_COMPLEX sincosd (F_TYPE x)


Description

sincos() computes both the sine and cosine of x, measured in radians.

sincosd() computes both the sine and cosine of x, measured in degrees.

sincos(x) is defined as (sin x + icos y).

Exceptions

Exceptional Argument Routine Behavior
|x| = infinity Invalid argument
(sind) |x| < (180/pi) * min_float Underflow

sinh - Hyperbolic Sine


Interface

F_TYPE sinh (F_TYPE x)


Description

sinh() computes the hyperbolic sine of x.

sinh(x) is defined as (exp(x)-exp(-x))/2.

Exceptions

Exceptional Argument Routine Behavior
|x| > ln(2 * max_float) Overflow

See Also

Appendix A, Critical Floating-Point Values

sinhcosh - Hyperbolic Sine and Cosine


Interface

F_COMPLEX sinhcosh (F_TYPE x)


Description

sinhcosh() computes both the hyperbolic sine and hyperbolic cosine of x.

sinhcosh(x) is defined as (sinh x + icosh x).

Exceptions

Exceptional Argument Routine Behavior
|x| > ln(2 * max_float) Overflow

See Also

Appendix A, Critical Floating-Point Values


Previous Next Contents Index

  [Go to the documentation home page] [How to order documentation] [Help on this site] [How to contact us]  
  privacy and legal statement  
6118PRO_003.HTML