Number.toFixed() (Method)

Converts the number to a fixed format representation.


ECMAScript edition - 3
JavaScript - 1.5
JScript - 5.5
Internet Explorer - 5.5
Netscape - 6.0
Property/method value type:String primitive
JavaScript syntax:-myNumber.toFixed(aNumber)
Argument list:aNumberThe number of digits after the decimal point

This method is useful for rounding and formatting number values. This is especially helpful when presenting tables of financial data which needs to be justified and padded to the same number of digits after the decimal point.

The argument value indicates the precision or decimal places of accuracy to the right of the decimal point character. If the argument is undefined, then zero is assumed and the value will be presented as an integer.

This method may be useful for performing truncations from floating point to integer value. The output of this method may also be more precise when a large number of integer digits are required to present the number. According to the ECMA standard, the alternative toString() method loses some accuracy for numbers having 19 digits for example.

See also:Number.toExponential(), Number.toPrecision(), Number.toString()


ECMA 262 edition 3 - section -