숫자보다 작거나 같은 가장 큰 정수를 얻으려면 JavaScript에서 Math.floor() 메서드를 사용하세요.
예시
다음 코드를 실행하여 숫자보다 작거나 같은 가장 큰 정수를 얻을 수 있습니다. -
<html>
<head>
<title>JavaScript Math floor() Method</title>
</head>
<body>
<script>
var value = Math.floor(50.3);
document.write("First Value : " + value );
var value = Math.floor(20.7);
document.write("<br />Second Value : " + value );
var value = Math.floor(-5.8);
document.write("<br />Third Value : " + value );
var value = Math.floor(-3.1);
document.write("<br />Fourth Value : " + value );
</script>
</body>
</html>