Math.FormatNumber
-----------------

Formats a number.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Math](component_Math.md) | [11.1](newinversion111.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Math.FormatNumber"; Value { ; Digits; Decimal Separator; Thousands Separator } ) 

**MBS**( **"Math.FormatNumber";** /\* Formats a number. \*/  
**$Value**; /\* The number to format.e.g. 123 \*/   
**$Digits**; /\* Optional; Number of digits.  
Can be zero when there should be no digits after decimal separator.  
Default is zero. Maximum 12. Values are rounded.e.g. 3 \*/   
**$Decimal Separator**; /\* Optional; The decimal separator.  
If empty, we detect the current setting from FileMaker.  
Can also be explicitly given as "." or ",".e.g. "." \*/   
**$Thousands Separator**) /\* Optional; 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. \*/ 

### 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. Maximum 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) &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; 12,34; 2; ",") &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; 0,001; 3; "") &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; 123456789,1235; 3; ""; ".")  
<small>  
Example result:   
123  
12,34  
0.001  
123,456,789.124</small>Try negative numbers:

 MBS ("Math.FormatNumber"; -123) &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; -12,34; 2; ",") &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; -0,001; 3; "") &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; -123456789,1235; 3; ""; ".")  
<small>  
Example result:   
-123  
-12,34  
-0.001  
-123,456,789.124</small>Try huge number:

 MBS ("Math.FormatNumber"; 1234567890123456789012345678901234567890,1234567890; 8; ","; ".")  
<small>  
Example result: 1.234.567.890.123.456.789.012.345.678.901.234.567.890,12345679</small>Format currency:

 MBS ("Math.FormatNumber"; $amount ; 2; ","; ".") &amp; " €"  
Try various numbers:

 MBS ("Math.FormatNumber"; 12,3456 ; 3 ; "."; "" ) &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; 12,3456 ; 6 ; "."; "" ) &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; 12,3456 ; 9 ; "."; "" ) &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; 12,3456 ; 10 ; "."; "" ) &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; 12,3456 ; 11 ; "."; "" ) &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; 12,3456 ; 12 ; "."; "" ) &amp; ¶ &amp;  
MBS ("Math.FormatNumber"; 12,3456 ; 20 ; "."; "" )  
<small>  
Example result:   
12.346  
12.345600  
12.345600000  
12.3456000000  
12.34560000000  
12.345600000000  
12.34560000000000000000</small>### See also

- [Matrix.CSV](MatrixCSV.md)

### Release notes

- **Version 16.3**
    - Fixed a bug in [Math.FormatNumber](https://www.mbsplugins.eu/MathFormatNumber.shtml) function, introduced in pr1.
- **Version 15.0**
    - Improved [Math.FormatNumber](https://www.mbsplugins.eu/MathFormatNumber.shtml) function to work better with 11 or more digits.
- **Version 11.1**
    - Added [Math.FormatNumber](https://www.mbsplugins.eu/MathFormatNumber.shtml) function.
    - Fixed problem in [Math.FormatNumber](https://www.mbsplugins.eu/MathFormatNumber.shtml) with missing zero before decimal separator for small number.

### Example Databases

- [WebViewer/WebViewer YouTube](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebViewer/WebViewer%20YouTube.shtml#3ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 16.3pr2](https://www.mbsplugins.de/archive/2026-06-15/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.0pr8](https://www.mbsplugins.de/archive/2025-01-07/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, June 2021 News](https://www.mbsplugins.de/archive/2021-06-01/MBS_FileMaker_Plugin_June_2021/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.1](https://www.mbsplugins.de/archive/2021-03-16/MBS_FileMaker_Plugin_111/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 11.1](https://www.mbsplugins.de/archive/2021-03-09/Neues_MBS_FileMaker_Plugin_111/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.1](https://www.mbsplugins.de/archive/2021-03-09/MBS_FileMaker_Plugin_111/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.1pr7](https://www.mbsplugins.de/archive/2021-03-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.1pr5](https://www.mbsplugins.de/archive/2021-02-20/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 22nd January 2019 , last changed 17th December 2025

  
[Math.EncodeNumber](MathEncodeNumber.md) - [Math.GetBit](MathGetBit.md)

[HTML Version](MathFormatNumber.shtml)