C# Math Pow
Description
Math Pow
returns a specified number raised to the specified
power.
Syntax
Math.Pow
has the following syntax.
public static double Pow(
double x,
double y
)
Parameters
Math.Pow
has the following parameters.
x
- A double-precision floating-point number to be raised to a power.y
- A double-precision floating-point number that specifies a power.
Returns
Math.Pow
method returns The number x raised to the power y.
Example
The following example uses the Pow method to calculate the value that results from raising 2 to a power ranging from 0 to 32.
using System;/* w w w . j ava2 s. c om*/
public class Example
{
public static void Main()
{
int value = 2;
for (int power = 0; power <= 32; power++)
Console.WriteLine("{0}^{1} = {2:N0} (0x{2:X})",
value, power, (long)Math.Pow(value, power));
}
}
The code above generates the following result.