I need to round floating point numbers up to the nearest integer, even if the number after the point is less than 0.5.
For example,
Use ceil
var n = 4.3;
n = Math.ceil(n);// n is 5
Round up to the second (0.00) decimal point:
var n = 35.85001;
Math.ceil(n * 100) / 100; // 35.86
to first (0.0):
var n = 35.800001;
Math.ceil(n * 10) / 10; // 35.9
to integer:
var n = 35.00001;
Math.ceil(n); // 36
jsbin.com
Use
Math.ceil( floatvalue );
It will round the value as desired.
Use the Math.ceil[MDN] function
var n = 4.3;
alert(Math.ceil(n)); //alerts 5