Math.Pow(Double, Double) 메서드

정의

지정된 전원에 대해 발생한 지정된 숫자를 반환합니다.

public:
 static double Pow(double x, double y);
public static double Pow(double x, double y);
static member Pow : double * double -> double
Public Shared Function Pow (x As Double, y As Double) As Double

매개 변수

x
Double

전원으로 올릴 배정밀도 부동 소수점 숫자입니다.

y
Double

전원을 지정하는 배정밀도 부동 소수점 숫자입니다.

반품

전원x에 발생된 숫자 y 입니다.

예제

다음 예제에서는 메서드를 Pow 사용 하 여 0에서 32에 이르기까지 전원에 2를 발생 시키는 결과 값을 계산 합니다.

int value = 2;
for (int power = 0; power <= 32; power++)
   Console.WriteLine($"{value}^{power} = {(long)Math.Pow(value, power):N0} (0x{(long)Math.Pow(value, power):X})");

// The example displays the following output:
//     2^0 = 1 (0x1)
//     2^1 = 2 (0x2)
//     2^2 = 4 (0x4)
//     2^3 = 8 (0x8)
//     2^4 = 16 (0x10)
//     2^5 = 32 (0x20)
//     2^6 = 64 (0x40)
//     2^7 = 128 (0x80)
//     2^8 = 256 (0x100)
//     2^9 = 512 (0x200)
//     2^10 = 1,024 (0x400)
//     2^11 = 2,048 (0x800)
//     2^12 = 4,096 (0x1000)
//     2^13 = 8,192 (0x2000)
//     2^14 = 16,384 (0x4000)
//     2^15 = 32,768 (0x8000)
//     2^16 = 65,536 (0x10000)
//     2^17 = 131,072 (0x20000)
//     2^18 = 262,144 (0x40000)
//     2^19 = 524,288 (0x80000)
//     2^20 = 1,048,576 (0x100000)
//     2^21 = 2,097,152 (0x200000)
//     2^22 = 4,194,304 (0x400000)
//     2^23 = 8,388,608 (0x800000)
//     2^24 = 16,777,216 (0x1000000)
//     2^25 = 33,554,432 (0x2000000)
//     2^26 = 67,108,864 (0x4000000)
//     2^27 = 134,217,728 (0x8000000)
//     2^28 = 268,435,456 (0x10000000)
//     2^29 = 536,870,912 (0x20000000)
//     2^30 = 1,073,741,824 (0x40000000)
//     2^31 = 2,147,483,648 (0x80000000)
//     2^32 = 4,294,967,296 (0x100000000)
open System

let value = 2
for power = 0 to 32 do
    printfn $"{value}^{power} = {Math.Pow(value, power) |> int64:N0} (0x{Math.Pow(value, power) |> int64:X})"

// The example displays the following output:
//     2^0 = 1 (0x1)
//     2^1 = 2 (0x2)
//     2^2 = 4 (0x4)
//     2^3 = 8 (0x8)
//     2^4 = 16 (0x10)
//     2^5 = 32 (0x20)
//     2^6 = 64 (0x40)
//     2^7 = 128 (0x80)
//     2^8 = 256 (0x100)
//     2^9 = 512 (0x200)
//     2^10 = 1,024 (0x400)
//     2^11 = 2,048 (0x800)
//     2^12 = 4,096 (0x1000)
//     2^13 = 8,192 (0x2000)
//     2^14 = 16,384 (0x4000)
//     2^15 = 32,768 (0x8000)
//     2^16 = 65,536 (0x10000)
//     2^17 = 131,072 (0x20000)
//     2^18 = 262,144 (0x40000)
//     2^19 = 524,288 (0x80000)
//     2^20 = 1,048,576 (0x100000)
//     2^21 = 2,097,152 (0x200000)
//     2^22 = 4,194,304 (0x400000)
//     2^23 = 8,388,608 (0x800000)
//     2^24 = 16,777,216 (0x1000000)
//     2^25 = 33,554,432 (0x2000000)
//     2^26 = 67,108,864 (0x4000000)
//     2^27 = 134,217,728 (0x8000000)
//     2^28 = 268,435,456 (0x10000000)
//     2^29 = 536,870,912 (0x20000000)
//     2^30 = 1,073,741,824 (0x40000000)
//     2^31 = 2,147,483,648 (0x80000000)
//     2^32 = 4,294,967,296 (0x100000000)
Public Module Example
   Public Sub Main
      Dim value As Integer = 2
      For power As Integer = 0 To 32
         Console.WriteLine("{0}^{1} = {2:N0} (0x{2:X})", _
                           value, power, CLng(Math.Pow(value, power)))
      Next
   End Sub
End Module
' The example displays the following output:
'     2^0 = 1 (0x1)
'     2^1 = 2 (0x2)
'     2^2 = 4 (0x4)
'     2^3 = 8 (0x8)
'     2^4 = 16 (0x10)
'     2^5 = 32 (0x20)
'     2^6 = 64 (0x40)
'     2^7 = 128 (0x80)
'     2^8 = 256 (0x100)
'     2^9 = 512 (0x200)
'     2^10 = 1,024 (0x400)
'     2^11 = 2,048 (0x800)
'     2^12 = 4,096 (0x1000)
'     2^13 = 8,192 (0x2000)
'     2^14 = 16,384 (0x4000)
'     2^15 = 32,768 (0x8000)
'     2^16 = 65,536 (0x10000)
'     2^17 = 131,072 (0x20000)
'     2^18 = 262,144 (0x40000)
'     2^19 = 524,288 (0x80000)
'     2^20 = 1,048,576 (0x100000)
'     2^21 = 2,097,152 (0x200000)
'     2^22 = 4,194,304 (0x400000)
'     2^23 = 8,388,608 (0x800000)
'     2^24 = 16,777,216 (0x1000000)
'     2^25 = 33,554,432 (0x2000000)
'     2^26 = 67,108,864 (0x4000000)
'     2^27 = 134,217,728 (0x8000000)
'     2^28 = 268,435,456 (0x10000000)
'     2^29 = 536,870,912 (0x20000000)
'     2^30 = 1,073,741,824 (0x40000000)
'     2^31 = 2,147,483,648 (0x80000000)
'     2^32 = 4,294,967,296 (0x100000000)

설명

다음 표에서는 값 및 x 매개 변수에 대해 다양한 값 또는 값 범위가 지정된 y 경우의 반환 값을 나타냅니다. 자세한 내용은 Double.PositiveInfinity, Double.NegativeInfinityDouble.NaN를 참조하세요.

x y 반환 값
다음을 제외한 모든 값 NaN ±0 1
NaN ±0 1(.NET Framework의 NaN)*
NaN 0을 제외한 모든 값 NaN*
±0 < 0 및 홀수 정수 NegativeInfinity 또는 PositiveInfinity
±0 NegativeInfinity PositiveInfinity
±0 PositiveInfinity +0
±0 > 0 및 홀수 정수 ±0
-1 NegativeInfinity 또는 PositiveInfinity 1
+1 다음을 제외한 모든 값 NaN 1
+1 NaN 1(.NET Framework의 NaN)*
1을 제외한 모든 값 NaN NaN*
-1 < x < 1 PositiveInfinity +0
< -1 또는 > 1 PositiveInfinity PositiveInfinity
-1 < x < 1 NegativeInfinity PositiveInfinity
< -1 또는 > 1 NegativeInfinity +0
PositiveInfinity < 0 +0
PositiveInfinity > 0 PositiveInfinity
NegativeInfinity < 0 및 유한 정수 및 홀수 -0
NegativeInfinity > 0 및 유한 정수 및 홀수 NegativeInfinity
NegativeInfinity < 0 및 유한하며 홀수 정수가 아님 +0
NegativeInfinity > 0 및 유한하며 홀수 정수가 아님 PositiveInfinity
±0 < 0 및 유한하며 홀수 정수가 아님 PositiveInfinity
±0 > 0 및 유한하며 홀수 정수가 아님 +0
< 0이지만 NegativeInfinity 정수가 아닌 유한 NaN

* 이러한 행은 Floating-Point 산술 연산에 대한 powIEEE 표준에 정의된 규칙의 전체 집합에 표시되지 않습니다. .NET IEEE 754 부동 소수점 예외를 사용하지 않도록 설정하여 qNaN(조용한 NaN)과 sNaN(신호 NaN)을 구분하지 않기 때문에 여기에 포함됩니다. IEEE 754 사양을 사용하면 이 예외를 사용하지 않도록 설정할 수 있습니다.

이 메서드는 기본 C 런타임을 호출하며 정확한 결과 또는 유효한 입력 범위는 운영 체제 또는 아키텍처 간에 다를 수 있습니다.

적용 대상

추가 정보