munifico.github.io

munifico's anything page

Follow me on GitHub

고정 소수점

소수점 뒤 자릴수를 지정하는 형식을 원한다면 toFixed()를 사용합니다.

x.toFixed(3);   // 19.510
x.toFixed(2);   // 19.51
x.toFixed(1);   // 19.5
x.toFixed(0);   // 20

이 숫자는 버림truncation이 아니라 반올림round 입니다.


이전 : 숫자 형식
다음 : 지수 표기법
목차