## Math.FormatNumber

Formats a number.

 Component Version macOS Windows Linux Server iOS SDK Math 11.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Math.FormatNumber"; Value { ; Digits; Decimal Separator; Thousands Separator } )   More

### Parameters

Parameter Description Example Flags
Value The number to format. 123
Digits Number of digits.
Can be zero when there should be no digits after decimal separator.
Default is zero. Maxium 12. Values are rounded.
3 Optional
Decimal Separator The decimal separator.
If empty, we detect the current setting from FileMaker.
Can also be explicitly given as "." or ",".
"." Optional
Thousands Separator The thousands separator.
Can be empty.
If you pass dot or comma and the same character is used for decimal separator, we switch to the other.
Optional

### Result

Returns OK or error.

### Description

Formats a number.
We format the number and you can specify whether we use comma or dot as decimal separator or detect it automatically from FileMaker's settings.
Thousands separator can be given.

### Examples

Format numbers:

MBS("Math.FormatNumber"; 123) & ¶ &
MBS("Math.FormatNumber"; 12,34; 2; ",") & ¶ &
MBS("Math.FormatNumber"; 0,001; 3; "") & ¶ &
MBS("Math.FormatNumber"; 123456789,1235; 3; ""; ".")

Example result:
123
12,34
0.001
123,456,789.124

Try negative numbers:

MBS("Math.FormatNumber"; -123) & ¶ &
MBS("Math.FormatNumber"; -12,34; 2; ",") & ¶ &
MBS("Math.FormatNumber"; -0,001; 3; "") & ¶ &
MBS("Math.FormatNumber"; -123456789,1235; 3; ""; ".")

Example result:
-123
-12,34
-0.001
-123,456,789.124

Try huge number:

MBS("Math.FormatNumber"; 1234567890123456789012345678901234567890,1234567890; 8; ","; ".")

Example result: 1.234.567.890.123.456.789.012.345.678.901.234.567.890,12345679

Format currency:

MBS("Math.FormatNumber"; \$amount; 2; ","; ".") & " €"

### Videos

Created 22nd January 2019, last changed 11st March 2021

Feedback: Report problem or ask question.