HPlogo HP-UX Reference Volume 4 of 5 > p

pow(3M)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

pow(), powf() — power functions

SYNOPSIS

#include <math.h>

double pow(double x, double y);

float powf(float x, float y);

DESCRIPTION

The pow() function returns xy. If x is negative, y must be an integer value.

The powf() function is a float version of pow(); it takes float arguments and returns a float result. To use this function, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options.

powf() is not specified by any standard, but it is named in accordance with the conventions specified in the "Future Library Directions" section of the ANSI C standard.

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

Millicode versions of the pow() function are available. Millicode versions of math library functions are usually faster than their counterparts in the standard library. To use these versions, compile your program with the +Olibcalls or the +Oaggressive optimization option.

If an error occurs, the millicode versions return the value described in the RETURN VALUE section, but do not set errno.

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

RETURN VALUE

If x and y are both zero, pow() returns 1.0.

If x or y is NaN, pow() returns NaN.

If the correct value after rounding would be smaller in magnitude than MINDOUBLE, pow() returns zero.

If x is zero and y is less than zero, pow() returns -HUGE_VAL and sets errno to [EDOM].

If x is less than zero and y is not an integer, pow() returns NaN and sets errno to [EDOM].

If the correct value would overflow, pow() returns ±HUGE_VAL and sets errno to [ERANGE].

ERRORS

If pow() fails, errno is set to one of the following values.

[EDOM]

x is zero and y is less than zero.

[EDOM]

x is less than zero and y is not an integer.

[ERANGE]

The correct value would overflow.

STANDARDS CONFORMANCE

pow(): SVID3, XPG4.2, ANSI C

© Hewlett-Packard Development Company, L.P.