A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/cmath/pow/ below:

function

<cmath> <ctgmath>

pow
double pow (double base, double exponent);
     double pow  (double base     , double exponent);      float powf (float base      , float exponent);long double powl (long double base, long double exponent);
     double pow (double base     , double exponent);      float pow (float base      , float exponent);long double pow (long double base, long double exponent);     double pow (double base     , int exponent);long double pow (long double base, int exponent);
     double pow (double base     , double exponent);      float pow (float base      , float exponent);long double pow (long double base, long double exponent);     double pow (Type1 base      , Type2 exponent);        // additional overloads

Raise to power

Returns base raised to the power exponent:

baseexponent

Header

<tgmath.h>

provides a type-generic macro version of this function.


Additional overloads

are provided in this header (

<cmath>

) for other combinations of

arithmetic types

(

Type1

and

Type2

): These overloads effectively cast its arguments to

double

before calculations, except if at least one of the arguments is of type

long double

(in which case both are casted to

long double

instead).

This function is also overloaded in <complex> and <valarray> (see complex pow and valarray pow).



Parameters
base
Base value.
exponent
Exponent value.

Return Value The result of raising base to the power exponent.

If the base is finite negative and the exponent is finite but not an integer value, it causes a domain error.


If both base and exponent are zero, it may also cause a domain error on certain implementations.
If base is zero and exponent is negative, it may cause a domain error or a pole error (or none, depending on the library implementation).
The function may also cause a range error if the result is too great or too small to be represented by a value of the return type.

If a

domain error

occurs, the global variable

errno

is set to

EDOM

.

If a

pole

or

range error

occurs, the global variable

errno

is set

ERANGE

.



Example
1
2
3
4
5
6
7
8
9
10
11
/* pow example */
#include <stdio.h>      /* printf */
#include <math.h>       /* pow */

int main ()
{
  printf ("7 ^ 3 = %f\n", pow (7.0, 3.0) );
  printf ("4.73 ^ 12 = %f\n", pow (4.73, 12.0) );
  printf ("32.01 ^ 1.54 = %f\n", pow (32.01, 1.54) );
  return 0;
}

Output:
7 ^ 3 = 343.000000
4.73 ^ 12 = 125410439.217423
32.01 ^ 1.54 = 208.036691


See also
log
Compute natural logarithm (function)
exp
Compute exponential function (function)
sqrt
Compute square root (function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4