HPlogo HP-UX Reference > E

expm1(3M)

HP-UX 11i Version 2: December 2007 Update
» 

Technical documentation

 » Table of Contents

 » Index

NAME

expm1(), expm1f(), expm1l(), expm1w(), expm1q() — exponential minus 1 functions

SYNOPSIS

#include <math.h>

double expm1(double x);

Itanium(R)-based System Only

float expm1f(float x);

long double expm1l(long double x);

extended expm1w(extended x);

quad expm1q(quad x);

DESCRIPTION

The expm1() function is equivalent to exp(x) - 1, but may be more accurate for very small values of x.

The expm1() and log1p() functions are useful to guarantee that financial calculations of (((1+x)**n)-1)/x are accurate when x is very small, namely:

expm1(n * log1p(x))/x

The preceding example might be applicable when calculating small daily interest rates.

See also annuity().

Itanium-based System Only

expm1f() is a float version of expm1(); it takes a float argument and returns a float result.

expm1l() is a long double version of expm1(); it takes a long double argument and returns a long double result.

expm1w() is an extended version of expm1(); it takes an extended argument and returns an extended result.

expm1q() is equivalent to expm1l() on HP-UX systems.

USAGE

To use these functions, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options.

To use (for Itanium-based systems) expm1w() or expm1q(), compile also with the -fpwidetypes option.

Make sure your program includes <math.h>, and link in the math library by specifying -lm on the compiler or linker command line.

For more information, see the HP-UX Floating-Point Guide.

RETURN VALUE

expm1(±0) returns ±0.

If x is +INFINITY, expm1() returns +INFINITY.

If x is -INFINITY, expm1() returns -1.0.

If x is NaN, expm1() returns NaN.

expm1() returns infinity (equal to HUGE_VAL) in lieu of a value whose magnitude is too large, and raises the overflow and inexact exceptions.

When it raises no other exception, whether expm1() raises the inexact exception is unspecified.

ERRORS

If the correct value would overflow, expm1() sets errno to [ERANGE].

Itanium-based System Only

HP-UX libm functions on Itanium-based system do not set errno by default. For errno setting, compile with the +Olibmerrno option.

STANDARDS CONFORMANCE

expm1() : XPG4.2, ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')

expm1f(), expm1l() : ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')