RAD Studio |  |

pow, powl

Header File

math.h

Category

Math Routines

Prototype

double pow(double x, double y);

long double powl(long double x, long double y);

Description

Calculates x to the power of y.

powl is the long double version; it takes long double arguments and returns a long double result.

Return Value

On success, pow and powl return the value calculated of x to the power of y.

Sometimes the arguments passed to these functions produce results that overflow or are incalculable. When the correct value would overflow, the functions return the value HUGE_VAL (pow) or _LHUGE_VAL (powl). Results of excessively large magnitude can cause the global variable errno to be set to

ERANGE | Result out of range

If the argument x passed to pow or powl is real and less than 0, and y is not a whole number, or if x is 0 and y is less than 0, or you call pow(0,0), the global variable errno is set to

EDOM | Domain error

Error handling for these functions can be modified through the functions _matherr and _matherrl.

Example

Copy Code

    #include <math.h>
    #include <stdio.h>
    int main(void)
    {
      double x = 2.0, y = 3.0;
      printf("%lf raised to %lf is %lf\n", x, y, pow(x, y));
      return 0;
    }

Portability

| POSIX | Win32 | ANSI C | ANSI C++
pow | + | + | + | +
powl |  | + | + | +

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!