Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > C

compound(3M)

HP Integrity Server Only
HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

compound(), compoundf(), compoundl(), compoundw(), compoundq() — compound interest factor

SYNOPSIS

#include <math.h>

double compound(double rate, double periods);

float compoundf(float rate, float periods);

long double compoundl(long double rate, long double periods);

extended compoundw(extended rate, extended periods);

quad compoundq(quad rate, quad periods);

DESCRIPTION

The compound() function computes the compound interest factor:

(1 + rate) ** periods

compoundf() is a float version of compound(); it takes float arguments and returns a float result.

compoundl() is a long double version of compound(); it takes long double arguments and returns a long double result.

compoundw() is an extended version of compound(); it takes extended arguments and returns an extended result.

compoundq() is equivalent to compoundl() 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 compoundw() or compoundq(), compile also with the -fpwidetypes option. Make sure your program includes <math.h>.

Link in the math library by specifying -lm on the compiler or linker command line.

RETURN VALUE

If periods equals zero, compound() returns 1.0.

Else, if either argument is a NaN, compound() returns a NaN.

Else, if rate is less than -1, compound() returns a NaN and raises the invalid exception.

Else, if rate equals -1, compound() is equivalent to pow(0, periods).

Else, if rate equals +INFINITY, compound() is equivalent to pow(rate, periods).

Else, if periods is infinite and rate equals zero, compound() returns 1.0.

Else, if periods is infinite and rate does not equal zero, compound() is equivalent to exp(rate * periods).

compound() returns a properly signed infinity in lieu of a value whose magnitude is too large, and raises the overflow and inexact exceptions.

compound() raises the underflow and inexact exceptions whenever a result is tiny (essentially denormal or zero) and thereby suffers loss of accuracy, and may raise those exceptions if the result is merely tiny.

ERRORS

No errors are defined.

STANDARDS CONFORMANCE

These functions are not specified by any standard.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.