"함수 power()"의 두 판 사이의 차이

 
87번째 줄: 87번째 줄:
==Python==
==Python==
[[category: python]]
[[category: python]]
<syntaxhighlight lang='python'>
{{참고|파이썬 **}}
print(2**-3)
{{참고|파이썬 pow()}}
# 0.125
<syntaxhighlight lang='python' run>
print(3**4)
print(2**-3) # 0.125
# 81
print(3**4) # 81
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang='python'>
<syntaxhighlight lang='python' run>
print(pow(2,-3))
print(pow(2,-3)) # 0.125
# 0.125
print(pow(3,4)) # 81
print(pow(3,4))
# 81
</syntaxhighlight>
</syntaxhighlight>



2023년 10월 31일 (화) 02:48 기준 최신판

  다른 뜻에 대해서는 전력 문서를 참조하십시오.
  다른 뜻에 대해서는 power 문서를 참조하십시오.

1 개요[ | ]

power
pow
**
  • Returns base raised to the power of exp.
  • test set
power(2, -3) → 0.125
power(3, 4) → 81

2 C[ | ]

#include <stdio.h>
#include <math.h>
int main() {
    printf("%f\n", pow(2, -3)); // 0.125000
    printf("%f\n", pow(2, 10)); // 1024.000000
}

3 C++[ | ]

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    cout << pow(2, -3) << endl; // 0.125
    cout << pow(2, 10) << endl; // 1024
}

4 Excel[ | ]

=POWER(2,-3)
// 0.125
=POWER(3,4)
// 81

5 Java[ | ]

public class MyClass {
    public static void main(String args[]) {
        System.out.println( Math.pow(2, -3) ); // 0.125
        System.out.println( Math.pow(3, 0) ); // 1.0
        System.out.println( Math.pow(3, 1) ); // 3.0
        System.out.println( Math.pow(3, 2) ); // 9.0
        System.out.println( Math.pow(3, 4) ); // 81.0
    }
}

6 JavaScript[ | ]

console.log( Math.pow(2, -3) ); // 0.125
console.log( Math.pow(2, 3) );  // 8

7 Perl[ | ]

print 2**-3;
# 0.125
print 3**4;
# 81

8 PHP[ | ]

var_dump( pow(2, -3) ); # float(0.125)
var_dump( pow(3, 4) ); # int(81)

9 Python[ | ]

print(2**-3) # 0.125
print(3**4) # 81
print(pow(2,-3)) # 0.125
print(pow(3,4)) # 81

10 SQLite[ | ]

SELECT 3*3*3*3;

11 Ruby[ | ]

puts 2**-3
# 1/8
puts 3**4
# 81

12 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}