그만큼 java.lang.Math .pow() 다른 숫자의 거듭제곱을 계산하는 데 사용됩니다. 이 함수는 두 개의 매개변수를 받아들이고 첫 번째 매개변수의 값을 두 번째 매개변수로 반환합니다. 아래와 같은 특별한 경우가 있습니다.
- 두 번째 매개변수가 양수 또는 음수 0이면 결과는 1.0이 됩니다.
- 두 번째 매개변수가 1.0이면 결과는 첫 번째 매개변수와 동일합니다.
- 두 번째 매개변수가 NaN이면 결과도 NaN이 됩니다.
- 함수 java.lang.Math.pow() 항상 double 데이터 유형을 반환합니다.
통사론 :
public static double pow(double a, double b) Parameter : a : this parameter is the base b : this parameter is the exponent. Return : This method returns ab.>
실시예 1 : 작업하는 모습을 보여주기 위해 java.lang.Math.pow() 방법.
자바
리눅스 파일 시스템
// Java program to demonstrate working> // of java.lang.Math.pow() method> import> java.lang.Math;> class> Gfg {> >// driver code> >public> static> void> main(String args[])> >{> >double> a =>30>;> >double> b =>2>;> >System.out.println(Math.pow(a, b));> >a =>3>;> >b =>4>;> >System.out.println(Math.pow(a, b));> >a =>2.5>;> >b =>6.9>;> >System.out.println(Math.pow(a, b));> >}> }> |
>
>
산출:
900.0 81.0 556.9113382296638>
시간 복잡도: O(로그(b))
보조 공간: 오(1)
자바
멍청한 점
// Java program to demonstrate working> // of java.lang.Math.pow() method> import> java.lang.Math;>// importing java.lang package> public> class> GFG {> >public> static> void> main(String[] args)> >{> >double> nan = Double.NaN;> >double> result;> >// Here second argument is NaN,> >// output will be NaN> >result = Math.pow(>2>, nan);> >System.out.println(result);> >// Here second argument is zero> >result = Math.pow(>1254>,>0>);> >System.out.println(result);> >// Here second argument is one> >result = Math.pow(>5>,>1>);> >System.out.println(result);> >}> }> |
셀레늄 튜토리얼
>
>
산출:
NaN 1.0 5.0>
시간 복잡도: O(로그(b))
보조 공간: 오(1)