Search

산술1_개념05_소수점

대분류
STEP01 프로그램설치/기초/산술/변수
문제 난이도
필수
소분류
산술1_개념

영상

개념

<script> /* [개념] 소수점 처리 [1] 올림 - Math.ceil(x) : 주어진 값에 소수점 올림하여 정수를 반환 [2] 버림 - Math.floor(x): 주어진 값에 소수점 내림하여 정수를 반환 [3] 반올림 - Math.round(x): 주어진 값에 소수점 반올림하여 정수를 반환 - 0, 1, 2, 3, 4이면 버리고, 5, 6, 7, 8, 9이면 올림 */ console.log(10 / 4); console.log(Math.ceil(10 / 4)); console.log(Math.floor(10 / 4)); console.log(Math.round(2.5)); console.log(Math.round(2.4)); document.write((10 / 4) + "<br>"); // 2.5 document.write(Math.ceil(10 / 4) + "<br>"); // 3 document.write(Math.floor(10 / 4) + "<br>"); // 2 document.write(Math.round(2.5) + "<br>"); // 3 document.write(Math.round(2.4) + "<br>"); // 2 </script>
Java
복사