This is the documentation for the development version. There are no official binaries for it; build it from the source code in git. Download links on these pages work only after the release. For the current release, see version 7.0.

FormatNumber

FormatNumber(number, width, precision, thousandSeparator): String

Formats a numeric value.

Table 1. Parameters

number

Any

The numeric value to format.

width

Integer

Optional, default 0. Minimum number of characters. If the number of characters in the output value is less than the specified width, blanks are added to the left or the right of the values — depending on whether the width is negative (for left alignment) or positive (for right alignment) — until the minimum width is reached. The width specification never causes a value to be truncated. Padding is applied before thousand separators are inserted, so separators make the result longer than width.

precision

Integer

Optional, default 0. The number of decimal places. Floating point value will be rounded accordingly.

thousandSeparator

String

Optional. String inserted between groups of three digits in the integer part. No grouping is done if omitted, null or empty.

Return

Formatted numeric value.

FormatNumber(3.7, 7, 2)		//	"   3.70"
FormatNumber(3.7, -7, 2)		//	"3.70   "
FormatNumber(5.7278, 1, 2)	//	"5.73"
FormatNumber(5.7278, 1, 0)	//	"6"
FormatNumber(1234567.891, 0, 2, ",")	//	"1,234,567.89"
FormatNumber(1234567, 12, 0, ",")	//	"     1,234,567"