javascript arrotondare per eccesso code example
Example 1: js arrotondare superiore numero
function roundTo(value, places){
var power = Math.pow(10, places);
return Math.round(value * power) / power;
}
var myNum = 10000/3;
roundTo(myNum, 2);
roundTo(myNum, 0);
roundTo(myNum, -2);
Example 2: js arrotondare superiore numero
var myNum = 2/3;
var multiplier = 100;
var a = Math.round(myNum * multiplier) / multiplier;
var b = Math.ceil (myNum * multiplier) / multiplier;
var c = Math.floor(myNum * multiplier) / multiplier;