JS 자바스크립트 소수점 버림, 올림, 반올림
Math.floor(변환할 값) ! 소수점 올리기var testnum = 99.11; alert(Math.ceil(testnum)); // 100 출력, 올림 적용 ! 소수점 버림var testnum = 99.11; alert(Math.floor(testnum)); // 99 출력, 버림 적용 ! 소수점 반올림var testnum = 99.5; alert(Math.round(testnum)); // 100 출력, 반올림 적용 ! toFixed()toFixed를 사용하면 숫자에서 원하는 소수점 길이만큼만 반올림하여서 반환해 준다. 아래는 간단한 예제이다. var testnum = 99.9876543; testnum.toFixed(0); // 100 출력 testnum.toFixed(5); // 99.987..