Home Communities
IT Knowledge
Inspiration
Languages
EN

# C# / .NET - Math.Pow() method example

0 points
Created by:
428

`Math.Pow()` is a static method that returns base raised to the power of exponent (`value^exponent` operation).

``````using System;

public class Program
{
public static void Main(string[] args)
{
//                          base  exponent
Console.WriteLine( Math.Pow(  1  ,  2       ) ); // 1
Console.WriteLine( Math.Pow(  2  ,  2       ) ); // 4
Console.WriteLine( Math.Pow(  3  ,  2       ) ); // 9

Console.WriteLine( Math.Pow(  0  ,  3       ) ); // 0
Console.WriteLine( Math.Pow(  0.5,  0.3     ) ); // 0.8122523963562356
Console.WriteLine( Math.Pow( -1  ,  4       ) ); // 1

Console.WriteLine( Math.Pow(  0  , -0.4     ) ); //  ∞ / +Infinity
Console.WriteLine( Math.Pow( -0.5, -2       ) ); // 4
Console.WriteLine( Math.Pow( -2.0, -2       ) ); // 0.25
Console.WriteLine( Math.Pow(  2.0 , 0.5     ) ); // 1.4142135623730951
}
}``````

## 1. Documentation

 Syntax ``````namespace System { public static class Math { // ... public static double Pow(double base, double exponent) { ... } // ... } }`````` Parameters The method takes a double arguments. `base` - base of power`exponent` - exponent used with a base Result `number` value (primitive value) calculated as base raised to the power of exponent or `NaN` if the operation can not be executed. Description `Pow` is a static method that returns base raised to the power of exponent (`value^exponent` operation).
Join to our subscribers to be up to date with content, news and offers.