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
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)
9 Python
Python
Copy
print(2**-3)
# 0.125
print(3**4)
# 81
Python
Copy
print(pow(2,-3))
# 0.125
print(pow(3,4))
# 81
10 SQLite
SQLite
Copy
SELECT 3*3*3*3;
Loading
11 Ruby
Ruby
Copy
puts 2**-3
# 1/8
puts 3**4
# 81