Computer >> 컴퓨터 >  >> 프로그램 작성 >> JavaScript

JavaScript의 Math.floor() 함수

<시간/>

Math 객체의 floor() 함수는 부동 소수점 숫자를 받아들이고 주어진 숫자보다 작거나 같은 가장 큰 정수를 반환합니다. 주어진 숫자 자체가 정수인 경우 이 함수는 동일한 값을 반환합니다.

구문

구문은 다음과 같습니다.

Math.floor(160)

예시

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var result = Math.floor(160.98);
      document.write("Floor value: "+result);
   </script>
</body>
</html>

출력

Floor value: 160