Export (0) Print
Expand All

Math.Pow Method

Returns a specified number raised to the specified power.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

static member Pow : 
        x:float * 
        y:float -> float

Parameters

x
Type: System.Double

A double-precision floating-point number to be raised to a power.

y
Type: System.Double

A double-precision floating-point number that specifies a power.

Return Value

Type: System.Double
The number x raised to the power y.

The following table indicates the return value when various values or ranges of values are specified for the x and y parameters. For more information, see Double.PositiveInfinity, Double.NegativeInfinity, and Double.NaN.

Parameters

Return value

x or y = NaN.

NaN

x = Any value except NaN; y = 0.

1

x = NegativeInfinity; y < 0.

0

x = NegativeInfinity; y is a positive odd integer.

NegativeInfinity

x = NegativeInfinity; y is positive but not an odd integer.

PositiveInfinity

x < 0 but not NegativeInfinity; y is not an integer, NegativeInfinity, or PositiveInfinity.

NaN

x = -1; y = NegativeInfinity or PositiveInfinity.

NaN

-1 < x < 1; y = NegativeInfinity.

PositiveInfinity

-1 < x < 1; y = PositiveInfinity.

0

x < -1 or x > 1; y = NegativeInfinity.

0

x < -1 or x > 1; y = PositiveInfinity.

PositiveInfinity

x = 0; y < 0.

PositiveInfinity

x = 0; y > 0.

0

x = 1; y is any value except NaN.

1

x = PositiveInfinity; y < 0.

0

x = PositiveInfinity; y > 0.

PositiveInfinity

The following example uses the Pow method to calculate the value that results from raising 2 to a power ranging from 0 to 32.

No code example is currently available or this language may not be supported.

The example displays output like the following:

       20 = 1 (0x1)
       21 = 2 (0x2)
       22 = 4 (0x4)
       23 = 8 (0x8)
       24 = 16 (0x10)
       25 = 32 (0x20)
       26 = 64 (0x40)
       27 = 128 (0x80)
       28 = 256 (0x100)
       29 = 512 (0x200)
       210 = 1,024 (0x400)
       211 = 2,048 (0x800)
       212 = 4,096 (0x1000)
       213 = 8,192 (0x2000)
       214 = 16,384 (0x4000)
       215 = 32,768 (0x8000)
       216 = 65,536 (0x10000)
       217 = 131,072 (0x20000)
       218 = 262,144 (0x40000)
       219 = 524,288 (0x80000)
       220 = 1,048,576 (0x100000)
       221 = 2,097,152 (0x200000)
       222 = 4,194,304 (0x400000)
       223 = 8,388,608 (0x800000)
       224 = 16,777,216 (0x1000000)
       225 = 33,554,432 (0x2000000)
       226 = 67,108,864 (0x4000000)
       227 = 134,217,728 (0x8000000)
       228 = 268,435,456 (0x10000000)
       229 = 536,870,912 (0x20000000)
       230 = 1,073,741,824 (0x40000000)
       231 = 2,147,483,648 (0x80000000)
       232 = 4,294,967,296 (0x100000000)

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft