함수 power()

Jmnote (토론 | 기여)님의 2022년 1월 25일 (화) 12:45 판 (→‎Python)
  다른 뜻에 대해서는 전력 문서를 참조하십시오.
  다른 뜻에 대해서는 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(3,4));
    // 81.000000
    printf("%d\n", (int)pow(3,4));
    // 81
}

3 Excel

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

4 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
    }
}

5 JavaScript

console.log( Math.pow(3,2) ); // 9

6 Perl

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

7 PHP

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

8 Python

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

9 SQLite

SELECT 3*3*3*3;

10 Ruby

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

11 같이 보기

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