Skip to main content
Version: 7.9

numberFormat

This function is used by Ignition's Expression language.

Description

Returns a string version of the number argument, formatted as specified by the pattern string. This is commonly used to specify the number of decimal places to display, but can be used for more advanced formatting as well. The pattern string is a numeric format string, which may include any of these characters that instruct it how to format the number.

SymbolDescription
0Specifies a required digit.
#Specifies an optional digit.
,The grouping separator.
.The decimal separator.
-A minus sign.
EScientific notation.
;Used to separate positive and negative patterns. The negative subpattern on the right will only be used to specify the prefix and suffix. The number of digits, , minimal digits, and other characteristics are all the same as the positive pattern.
%Multiplies the value by 100 and shows as a percent.
'Used to quote special characters.

This table shows some numbers, and the result of using various format strings to format them.

NumberPatternResult
505
50.05.0
500.005.0
123#,##0123
1024#,##01,024
1337#,##0.#1,337
1337.57#,##0.#1,337.6
87.32#,##0.000087.3200
-1234#,##0-1,234
-1234#,##0;(#)(1,234)
40960.###E04.096E3
.348#.00%34.80%
34.8#0.00'%'34.80%

Syntax

numberFormat(number, pattern)

  • Parameters

    • float number- The number to format.

    • string pattern - The format pattern.

  • Results

    • string - The string representation of the number formatted according to the pattern provided.

Examples

Code Snippet
numberFormat(34.8, "#0.00'%'") //returns the string "34.80%"