Convert Number to Fixed Decimal Method
The Convert Number to Fixed Decimal method converts a number according to the decimal places that you specify. It returns the number that it converts. It allows you to express a number that includes a number of decimal places that you specify. For example, to express the results of a currency calculation that includes two decimal places.
This method does the same work as the Convert Number to Exponential Notation method. For more information, see Convert Number to Exponential Notation Method.
This method uses the same argument as the Convert Number to Exponential Notation method. For more information, see Convert Number to Exponential Notation Method.
Format
numberVar.toFixed(len)
The following example uses the Convert Number to Fixed Decimal method:
var profits=2487.8235
var profits3 = profits.toFixed(3) //returns 2487.824
var profits2 = profits.toFixed(2) //returns 2487.82
var profits7 = profits.toFixed(7) //returns 2487.8235000
var profits0 = profits.toFixed(0) //returns 2488
var profitserr = profits.toFixed(-1) //throws error