Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter02 : Math 본문

WEB.JS/03.내장객체_JS

chapter02 : Math

GAWON 2023. 5. 19. 09:24
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Math</title>
<script type="text/javascript">
document.write("<h1>파이 : " + Math.PI + "</h1>");

```
document.write("<h1>제곱 : " + Math.pow(2,3) + "</h1>");
document.write("<h1>제곱 : " + (2 ** 3) + "</h1>");

document.write("<h1>절대값 : " + Math.abs(-10) + "</h1>");

document.write("<h1>루트 : " + Math.sqrt(4) + "</h1>");

document.write("<h1>최대값 : " + Math.max(1, 2, 3, 4, 5) + "</h1>");

document.write("<h1>최소값 : " + Math.min(1, 2, 3, 4, 5) + "</h1>");

document.write("<h1>정수로 반올림 : " + Math.round(123.456) + "</h1>");

document.write("<h1>소수 1자리 남기고 반올림 : " + (Math.round(123.456 * 10) / 10) + "</h1>");
document.write("<h1>소수 2자리 남기고 반올림 : " + (Math.round(123.456 * 100) / 100) + "</h1>");

document.write("<h1>올림 : " + Math.ceil(123.456) + "</h1>");		// 천장함수
document.write("<h1>내림 : " + Math.floor(123.456) + "</h1>");	// 바닥함수

```

</script>
</head>
<body>

</body>
</html>

'WEB.JS > 03.내장객체_JS' 카테고리의 다른 글

chapter03 : Random  (0) 2023.05.19
chapter01 : Date  (0) 2023.05.19