Javascript/ES6
Math 오브젝트
dongling
2024. 6. 12. 21:56
728x90
반응형
SMALL
🔶 Math 함수 목록
함수 이름개요
sinh() | 쌍곡 사인 |
asinh() | 쌍곡 아크사인 |
cosh() | 쌍곡 코사인 |
acosh() | 쌍곡 아크코사인 |
tanh() | 쌍곡 탄젠트 |
atanh() | 쌍곡 아크탄젠트 |
log1p() | 로그(1 + 파라미터 값) |
log10() | 밑이 10인 로그 |
log2() | 밑이 2인 로그 |
expm1() | 자연로그 상수(e)의 x승 -1 |
hypot() | 제곱근 |
cbrt() | 세제곱근 |
sign() | 사인(sign) 값 |
trunc() | 소수를 제외한 정수 |
imul() | 파라미터 값을 곱하고 결과를 32비트로 변환 |
clz32() | 32비트 값에서 0비트 수 |
fround() | 32비트 유동 소수 값 |
1. sinh() : 쌍곡 사인
console.log(Math.sinh(0)); // 0
console.log(Math.sinh(1)); // 1.1752011936438014
2. asinh() : 쌍곡 아크사인
console.log(Math.asinh(0)); // 0
console.log(Math.asinh(1)); // 0.881373587019543
3. cosh() : 쌍곡 코사인
console.log(Math.cosh(0)); // 1
console.log(Math.cosh(1)); // 1.5430806348152437
console.log(Math.cosh(-1)); // 1.5430806348152437
4. acosh() : 쌍곡 아크코사인
console.log(Math.acosh(0)); // NaN
console.log(Math.acosh(1)); // 0
console.log(Math.acosh(2)); // 1.3169578969248166
5. tanh() : 쌍곡 탄젠트
console.log(Math.tanh(0)); // 0
console.log(Math.tanh(1)); // 0.7615941559557649
console.log(Math.tanh(Infinity)); // 1
6. atanh() : 쌍곡 아크탄젠트
console.log(Math.atanh(-2)); // NaN
console.log(Math.atanh(2)); // NaN
console.log(Math.atanh(-1)); // -Infinity
console.log(Math.atanh(1)); // Infinity
console.log(Math.atanh(0)); // 0
console.log(Math.atanh(0.5)); // 0.5493061443340548
7. log2() : 밑이 2인 로그
console.log(Math.log2(3)); // 1.584962500721156
console.log(Math.log2(2)); // 1
console.log(Math.log2(1)); // 0
console.log(Math.log2(0)); // -Infinity
console.log(Math.log2(-1)); // NaN
8. log10() : 쌍곡 탄젠트
console.log(Math.log10(100)); // 2
console.log(Math.log10(10)); // 1
console.log(Math.log10(2)); // 0.3010299956639812
console.log(Math.log10(1)); // 0
console.log(Math.log10(-1)); // NaN
9. log1p() : 로그(1+값)
console.log(Math.log1p(1)); // 0.6931471805599453
console.log(Math.log1p(0)); // 0
console.log(Math.log1p(-1)); // -Infinity
console.log(Math.log1p(-2)); // NaN
10. expm1() : 자연로그 상수(e)의 x승 -1
console.log(Math.expm1(-1)); // -0.6321205588285577
console.log(Math.expm1(0)); // 0
console.log(Math.expm1(1)); // 1.718281828459045
console.log(Math.expm1(Infinity)); // Infinity
console.log(Math.expm1(-Infinity)); // -1
11. hypot() : 제곱근
console.log(Math.hypot(3)); // 3
console.log(Math.hypot(3, 4)); // 5
console.log(Math.hypot(3, 4, 5)); // 7.0710678118654755
console.log(Math.hypot()); // 0
console.log(Math.hypot(-3, -4)); // 5
12. cbrt() : 세제곱근
console.log(Math.cbrt(-1)); // -1
console.log(Math.cbrt(0)); // 0
console.log(Math.cbrt(1)); // 1
console.log(Math.cbrt(3)); // 1.4422495703074083
console.log(Math.cbrt(8)); // 2
13. sign() : 사인 값
console.log(Math.sign(NaN)); // NaN
console.log(Math.sign(0)); // 0
console.log(Math.sign(-0)); // -0
console.log(Math.sign(1)); // 1
console.log(Math.sign(-1)); // -1
14. trunc() : 소수를 제외한 정수
console.log(Math.trunc(12.78)); // 12
console.log(Math.trunc(0.12)); // 0
console.log(Math.trunc(-0.12)); // -0
console.log(Math.trunc(-1.23)); // -1
console.log(Math.trunc()); // NaN
console.log(Math.trunc(NaN)); // NaN
15. imul() : 32비트로 반환
console.log(Math.imul(2, 4)); // 8
console.log(Math.imul(-3, -4)); // 12
console.log(Math.imul(123456, 1000)); // 123456000
console.log(Math.imul(123456, 10000)); // 1234560000
console.log(Math.imul(123456, 100000)); // -539301888
16. clz32() : 32비트로 값에서 0비트 수
console.log(Math.clz32(1)); // 31
console.log(Math.clz32(2)); // 30
console.log(Math.clz32()); // 32
console.log(Math.clz32(2.5)); // 30
console.log(Math.clz32(true)); // 31
17. fround() : 32비트 유동 소수 값
let value = 0.1 + 0.2;
console.log(value); // 0.30000000000000004
console.log(Math.fround(value)); // 0.30000001192092896
console.log(1.23); // 1.23
console.log(Math.fround(1.23)); // 1.2300000190734863
728x90
반응형
LIST