|
The ESQL/C library provides special functions that allow you to format numeric expressions as strings. These numeric-formatting functions apply a given formatting mask to a numeric value to allow you to line up decimal points, right- or left-justify the number, enclose a negative number in parentheses, and so on. The ESQL/C library includes the following functions that support numeric-formatting masks for numeric values.
Tip: Both the ESQL/C library and the DataBlade API library provide functions to convert between mi_decimal values and other C-language data types. For more information, see Converting Decimal Data.
This section describes the characters that you can use to create a numeric- formatting mask. It also provides extensive examples that show the results of applying these masks to numeric values. A numeric-formatting mask specifies a format to apply to some numeric value. This mask is a combination of the following formatting characters:
Any other characters in the formatting mask are reproduced literally in the result.
When you use the following characters within a formatting mask, the characters float; that is, multiple occurrences of the character at the left of the pattern in the mask appear as a single character as far to the right as possible in the formatted number (without removing significant digits)
For example, if you apply the mask $$$,$$$.## to the number 1234.56, the result is $1,234.56.
When you use rfmtdec(), rfmtdouble(), or rfmtlong() to format MONEY values, the function uses the currency symbols that the DBMONEY environment variable specifies. If you do not set this environment variable, the numeric-formatting functions use the currency symbols that the client locale defines. The default locale, U.S. English, defines currency symbols as if you set DBMONEY to $,. . (For a discussion of DBMONEY, see the Informix Guide to SQL: Reference). For more information on locales, see the Informix Guide to GLS Functionality.
Figure 3-3 shows sample format strings for numeric expressions. The character b represents a blank or space.
Figure 3-3