Tech/JavaScript 자바스크립트에서의 소수점 제어 Enrai 2016. 6. 23. 11:46 1. toFixed() 원하는 소수점 길이만큼 반올림해서 리턴1234var num = 123.456789; num.toFixed(0); // 123num.toFixed(5); // 123.45679cs2. Math 소수점 부분을 처리하고 정수만을 획득Math.ceil() : 올림Math.floor() : 버림Math.round() : 반올림12345var num = 0.5; Math.ceil(num); // 1Math.floor(num); // 0Math.round(num); // 1cs 저작자표시 비영리 (새창열림)