IR Framework

Number.stringFormat Method

Formats a number according to a specific, user-defined format.
object.stringFormat (NumberFormat)

Arguments

object
Required. Always the name of a Number object.


NumberFormat
Required. A string that defines the output format using the codes shown in Settings. Other characters in NumberFormat are interpreted literally.



Settings

The Number.stringFormat method uses the following formatting codes:
This format pattern Causes this output
[#0],[#0] Includes a thousands separator
0 before . Includes a leading digit (0) if the number is between -1 and 1
0 or # after . Includes a digit after the decimal point for each 0 in the format string
$ Prepends a dollar sign
% Divides the number by 100 and appends a percent symbol

Return Value

The Number.stringFormat method returns a string representing the Number formatted according to the formatting pattern specified in NumberFormat.

Remarks

The following example illustrates the use of the Number.stringFormat method.

var n = new Number(12345.678);

Alert(n.format("#,0.0#"));	//	returns 12,345.68


Requirements

Number.format(), Number.currencyFormat(), Number.percentFormat(), String.inStr()