Does anybody know how to round a number that is displayed? (two or three decimal places max)
So I have:
export function button3_click(event) {
let A=Number($w("#input127").value);
let B=Number($w("#input128").value);
let C=Number($w("#input129").value);
let D =Number($w("#input130").value);
let Resultado5 = A*B*(1-C)+A/C
let Resultado3 = Resultado5/D
$w("#text44").text = Resultado3.toString();
}
The problem is that the result is always shown with a lot of decimal places..
@jpvac A function needs to be written to handle this.
function RoundDecimal(num, dec){ // in case number is less than 0 let GrLessZero = num >= 0 ? 1 : -1; return (Math.round((num * Math.pow(10, dec)) + (GrLessZero * 0.0001)) /Math.pow(10, dec)).toFixed(dec); }
Follow links for some documentation of the functions used.