toFixed (JavaScript)

Gets a string representation of a number using fixed-point notation.

Defined in

Number (Standard - JavaScript)

Syntax

toFixed() : string

toFixed(precision:int) : string
Parameters Description
precision The number of decimal places represented.
Return value Description
string The string value of the number in fixed-point notation.

Examples

This example prints a number in fixed-point format with default precision.
function p(stuff) {
 	print("<<<" + stuff + ">>>");
}

var n : Number;

try {
	n = new Number(12345E-2);
	p(n.toFixed()); // Prints <<<123.45>>>
	
} catch(e) {
	p("Error = " + e);
}