(→Python) |
|||
(사용자 2명의 중간 판 15개는 보이지 않습니다) | |||
1번째 줄: | 1번째 줄: | ||
[[category: math]] | [[category: math]] | ||
{{다른뜻|전력}} | {{다른뜻|전력}} | ||
{{다른뜻|power}} | |||
==개요== | ==개요== | ||
;power | ;power | ||
9번째 줄: | 10번째 줄: | ||
:power(2, -3) → 0.125 | :power(2, -3) → 0.125 | ||
:power(3, 4) → 81 | :power(3, 4) → 81 | ||
==C== | |||
{{참고|C언어 pow()}} | |||
<syntaxhighlight lang='c' run> | |||
#include <stdio.h> | |||
#include <math.h> | |||
int main() { | |||
printf("%f\n", pow(2, -3)); // 0.125000 | |||
printf("%f\n", pow(2, 10)); // 1024.000000 | |||
} | |||
</syntaxhighlight> | |||
==C++== | |||
[[분류: C++]] | |||
{{참고|C++ pow()}} | |||
<syntaxhighlight lang='cpp' run> | |||
#include <iostream> | |||
#include <cmath> | |||
using namespace std; | |||
int main() { | |||
cout << pow(2, -3) << endl; // 0.125 | |||
cout << pow(2, 10) << endl; // 1024 | |||
} | |||
</syntaxhighlight> | |||
==Excel== | ==Excel== | ||
[[category: Excel]] | [[category: Excel]] | ||
< | <syntaxhighlight lang='php'> | ||
=POWER(2,-3) | =POWER(2,-3) | ||
// 0.125 | // 0.125 | ||
=POWER(3,4) | =POWER(3,4) | ||
// 81 | // 81 | ||
</ | </syntaxhighlight> | ||
==Java== | ==Java== | ||
[[분류: Java]] | [[분류: Java]] | ||
{{참고|자바 pow()}} | {{참고|자바 pow()}} | ||
< | <syntaxhighlight lang='Java'> | ||
public class MyClass { | public class MyClass { | ||
public static void main(String args[]) { | public static void main(String args[]) { | ||
32번째 줄: | 58번째 줄: | ||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
==JavaScript== | ==JavaScript== | ||
[[category:JavaScript]] | [[category:JavaScript]] | ||
< | {{참고|JavaScript Math.pow()}} | ||
console.log( Math.pow(3, | <syntaxhighlight lang='JavaScript' run> | ||
</ | console.log( Math.pow(2, -3) ); // 0.125 | ||
console.log( Math.pow(2, 3) ); // 8 | |||
</syntaxhighlight> | |||
==Perl== | ==Perl== | ||
[[category:Perl]] | [[category:Perl]] | ||
< | <syntaxhighlight lang='perl'> | ||
print 2**-3; | print 2**-3; | ||
# 0.125 | # 0.125 | ||
print 3**4; | print 3**4; | ||
# 81 | # 81 | ||
</ | </syntaxhighlight> | ||
==PHP== | ==PHP== | ||
[[category: PHP]] | [[category: PHP]] | ||
{{참고|PHP pow()}} | {{참고|PHP pow()}} | ||
< | <syntaxhighlight lang='php' run> | ||
var_dump( pow(2, -3) ); | var_dump( pow(2, -3) ); # float(0.125) | ||
# float(0.125) | var_dump( pow(3, 4) ); # int(81) | ||
var_dump( pow(3, 4) ); | </syntaxhighlight> | ||
# int(81) | |||
</ | |||
==Python== | ==Python== | ||
[[category: python]] | [[category: 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 lang='python' run> | ||
print(pow(2,-3)) | print(pow(2,-3)) # 0.125 | ||
# 0.125 | print(pow(3,4)) # 81 | ||
print(pow(3,4)) | </syntaxhighlight> | ||
# 81 | |||
</ | ==SQLite== | ||
<syntaxhighlight lang='sqlite3' run> | |||
SELECT 3*3*3*3; | |||
</syntaxhighlight> | |||
==Ruby== | ==Ruby== | ||
[[category: Ruby]] | [[category: Ruby]] | ||
< | <syntaxhighlight lang='Ruby'> | ||
puts 2**-3 | puts 2**-3 | ||
# 1/8 | # 1/8 | ||
puts 3**4 | puts 3**4 | ||
# 81 | # 81 | ||
</ | </syntaxhighlight> | ||
==같이 보기== | ==같이 보기== |
2023년 10월 31일 (화) 02:48 기준 최신판
1 개요[ | ]
- power
- pow
- **
- Returns base raised to the power of exp.
- test set
- power(2, -3) → 0.125
- power(3, 4) → 81
2 C[ | ]

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

C++
Copy
#include <iostream>
#include <cmath>
using namespace std;
int main() {
cout << pow(2, -3) << endl; // 0.125
cout << pow(2, 10) << endl; // 1024
}
Loading
4 Excel[ | ]
PHP
Copy
=POWER(2,-3)
// 0.125
=POWER(3,4)
// 81
5 Java[ | ]

Java
Copy
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[ | ]

JavaScript
Copy
console.log( Math.pow(2, -3) ); // 0.125
console.log( Math.pow(2, 3) ); // 8
▶ | 0.125 |
▶ | 8 |
7 Perl[ | ]
Perl
Copy
print 2**-3;
# 0.125
print 3**4;
# 81
8 PHP[ | ]

PHP
Copy
var_dump( pow(2, -3) ); # float(0.125)
var_dump( pow(3, 4) ); # int(81)
Loading
9 Python[ | ]


Python
Copy
print(2**-3) # 0.125
print(3**4) # 81
Loading
Python
Copy
print(pow(2,-3)) # 0.125
print(pow(3,4)) # 81
Loading
10 SQLite[ | ]
SQLite
Copy
SELECT 3*3*3*3;
Loading
11 Ruby[ | ]
Ruby
Copy
puts 2**-3
# 1/8
puts 3**4
# 81
12 같이 보기[ | ]
로그인하시면 댓글을 쓸 수 있습니다.
리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― …리눅스 Python 2.7 컴파일 설치 ― Jmnote리눅스 Python 2.7 컴파일 설치 ― ㅇㅇㅇ미운코딩새끼 ― 승호 도령미운코딩새끼 ― 불탄고등어미운코딩새끼 ― 김레이미운코딩새끼 ― 호박이미운코딩새끼 ― Junhg0211미운코딩새끼 ― 김왼손미운코딩새끼 ― 용딘이미운코딩새끼 ―Pinkcrimson
유기농냠냠파이썬 ― 호박유기농냠냠파이썬 ― 이에스유기농냠냠파이썬 ― 이승현파이썬 global ― Jmnote파이썬 global ― John Jeong파이썬 global ― Jmnote파이썬 global ― John Jeong파이썬 global ― John Jeong파이썬 global ― John Jeong파이썬 global ― Jmnote파이썬 global ― John Jeong