Purpose
Returns a string representing a number, including thousands separators and decimal-place separators that match the user's system configuration. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
FormatNumber$( num, precision )
num is a numeric value or a string that represents a numeric value, such as "1234.56".
precision formats a float number as per the precision. Minimum value is 6 and maximum value is 14. (This parameter will only work when input type is float or decimal.)
Return Value
String
Description
Returns a string that represents a number. If the number is large enough to need a thousands separators, this function inserts thousands separators. MapInfo Pro reads the user's system configuration to determine which characters to use as the thousands separator and decimal separator.
Examples
The following table demonstrates how the FormatNumber$() function with a comma as the thousands separator and period as the decimal separator (United States defaults):
Function Call | Result returned |
---|---|
|
"12,345.67" (inserted a thousands separator) |
|
"12,345.67" (no change) |
|
"1234.57" |
|
"1234.568" |
If the user's computer is set up to use period as the thousands separator and comma as the decimal separator, the following table demonstrates the results:
Function Call | Result returned |
---|---|
|
"12.345,67" (inserted a thousands separator, and changed the decimal separator to match user's setup) |
|
"12.345,67" (changed both characters to match the user's setup) |
See Also:
DeformatNumber$() function