Possible Duplicate:
jQuery: rounding numbers to 2 digits after comma
While printing out a number in JavaScript, I only want keep only three digits after the decimal point. The code I am using shows more than 8 digits after the decimal point. Could anyone guide me on how to remove the remaining digits using JavaScript.
This is my JavaScript code:
function doMath() {
var nvalue; var amount;
var price= 0.27;
nvalue = document.getElementById("message").value;
amount=(nvalue*price);
document.getElementById("total").value=amount ;
}
Output:
4.050000000000001
I want:
4.050
Any help would be appreciated, thank you.