Export (0) Print
Expand All
Expand Minimize
6 out of 9 rated this helpful - Rate this topic

pow, powf

Calculates x raised to the power of y.

double pow(
   double x,
   double y 
);
double pow(
   double x,
   int y
);  // C++ only
double pow(
   int x,
   int y
);  // C++ only
float pow(
   float x,
   float y 
);  // C++ only
float pow(
   float x,
   int y
);  // C++ only
long double pow(
   long double x,
   long double y
);  // C++ only
long double pow(
   long double x,
   int y
);  // C++ only
float powf(
   float x,
   float y 
);

Parameters

x
Base.
y
Exponent.

Return Value

Returns the value of xy. No error message is printed on overflow or underflow.

Values of x and y Return value of pow
x < > 0 and y = 0.0 1
x = 0.0 and y = 0.0 1
x = 0.0 and y < 0 INF

Remarks

The pow function computes x raised to the power of y.

pow does not recognize integral floating-point values greater than 264, such as 1.0E100.

pow has an implementation that uses Streaming SIMD Extensions 2 (SSE2). See _set_SSE2_enable for information and restrictions on using the SSE2 implementation.

C++ allows overloading, so you can call any of the various overloads of pow. In a C program, pow always takes two double values and returns a double value.

Requirements

Routine Required header Compatibility
pow, powf <math.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

Example

// crt_pow.c

#include <math.h>
#include <stdio.h>

int main( void )
{
   double x = 2.0, y = 3.0, z;

   z = pow( x, y );
   printf( "%.1f to the power of %.1f is %.1f\n", x, y, z );
}

Output

2.0 to the power of 3.0 is 8.0

See Also

Floating-Point Support Routines | exp | log | sqrt | Run-Time Routines and .NET Framework Equivalents

Show:
© 2014 Microsoft. All rights reserved.