CodeCharge Studio

Number Format

SignDescriptionExampleNumberResult
0 Digit placeholder with fixed length (000) 000-00-00 121231212 (012) 123-12-12
# Digit placeholder. Insignificant zeros are not displayed. #.00 123.1 123.10
. Decimal separator. #.00 123.1 123.10
, Group separator. #,###.00 1234.1 1,234.10
% Percent notation #.#% 0.123 12.3%
\c literal character "c" \#0 10.1 #10
; Section separator.
[Color] Specifies the color that will be used for output. #.#;[Red]#.# -1.45 <font color="Red">-1.45</font>
{} Condition formatting. {$ > 10}[Red]#.#;#.# 100.01 <font color="Red">100.01</font>
$ Represent the name of the variable that will be used in the code.
E.g. the condition {$ > 10} specifies that the current mask
will be applied only when the amount is greater than 10.

Sections

The number formatting mask consists of four predefined sections.

positive number format;negative number format;zero number format;Null number format;decimal separator;group separator

The default values for decimal separator and for the group separator will be taken from the regional settigns in case the programming language supports the localized output of numbers. If the group separator was not presented in the mask then the number would not be devided at the groups. If the decimal separator not presented then will be displayed only the integer part of number.

Condition formatting

You may use the condition formatting if want to specify the exact format for the range. Use the {} in order to specify the condition that will be used for this mask. Note that in the condition you may use the language specific operators and functions and the condition is not language independed. If you have the masks with condition and without them then the first mask without condition is used for default formatting for positive numbers, second mask without condition is used for for default formatting of the negative numbers. If more than one mask can be applied then the leftmost mask with condition will be applied.

Examples

MaskNumbersResults
{$ > 10}[Red]#.#;{0 =< $ < 10}#.#;{$ < 0}(#.#) 10.01
5
-20
<font color="Red">10.01</font>
5
(20)


On-line, printable versions and updates