Description

Calculates the value of a number raised to a power. pow() can be used to raise a number to a fractional power. This is useful for generating exponential mapping of values or curves.

Syntax

Use the following function to raise a number to a given power:

pow(base, exponent)

Parameters

The function admits the following parameters:

  • base: the function input number to compute. Allowed data types: float.
  • exponent: the power to which the base is raised. Allowed data types: float.

Returns

The function returns the result of the exponentiation. Data type: double.

Example Code

Calculate the value of x raised to the power of y:

float x = 2.0;  // base number
float y = 10.0;  // exponent number

void setup() {
  Serial.begin(9600);

  double z = pow(x, y);

  Serial.print("The power result is: ");
  Serial.println(z);
}

void loop() {
}

See also