Help - Decimal format
Decimal formats can be applied to any text element such as nodes, text labels or legends. The decimal format of a scale bar also affects its scale labels. You can change the decimal formats using the element formats-dialog.
Contents
Format
Syntax
A decimal format pattern comprises of a prefix, number formats and a suffix. The prefix and suffix are optional and allow you to display any character sequence in front and behind the formated decimal value. This could e.g. be brackets using a pattern like "[0.00]
". The number format itself can consist of a combination of the following special symbols which stand for special characters like the localized decimal separator or a part of the value (e.g. "0
" or "#
"). All symbols listed below must be masked with "'
" if they shall be displayed in the prefix or suffix (see table for details).
Symbol | Location | Meaning |
---|---|---|
0 |
Number | Digit. If this symbol is used behind the decimal separator a zero will be displayed if the value does not contain any more decimal places. (See examples below.) |
# |
Number | Digit. If this symbol is used behind the decimal separator nothing will be displayed if the value does not contain any more decimal places. (See examples below.) |
. |
Number | Decimal separator |
- |
Number | Minus sign. Only useful in the negative subpattern (see below). |
, |
Number | Grouping separator (e.g. for thousands) |
E |
Number | Separates mantissa and exponent in scientific notation. (Needs not be quoted in prefix or suffix.) |
% |
Prefix or suffix | Value is multiplied by 100 and shown as percentage. |
' |
Prefix or suffix | Used to quote special characters in a prefix or suffix, for example, "'#' # " formats 123 to "# 123". To create a single quote itself, use two in a row: "# o''clock ". |
The grouping separator is commonly used for thousands, but in some countries it separates ten-thousands. The grouping size is a constant number of digits between the grouping characters, such as 3 for 100,000,000 or 4 for 1,0000,0000. If you supply a pattern with multiple grouping characters, the interval between the last one and the end of the integer is the one that is used. (The formats "######,####
", "##,####,####
" and "#,##,###,####
" will lead to the same result where the last example is not really a sense making format.)
Additionally a decimal format pattern can be composed of a positive and negative subpattern which are separated by a ";
" if you want to display positive and negative values differently. The negative subpattern is optional. If absent the positive subpattern prefixed with the localized minus sign ('-' in most locales) is used as the negative subpattern. (i.e. "0.00
" is equivalent to "0.00;-0.00
" but not to e.g. "0.00;[-0.00]
") Negative subpatterns serve only to specify the negative prefix and suffix. The number of digits, minimal digits, and other characteristics are all the same as the positive pattern. That means that "#,##0.0#;(#)
" produces precisely the same behavior as "#,##0.0#;(#,##0.0#)
".
Locale
You can specify the locale here which influences e.g. the decimal separator which is used to display the value in the document. (Note that this does not influence the syntax where the decimal separator is always ".
") When you create an XTG file where a certain locale is used you have to be aware that you can only display this file correctly on systems where this locale is available.
Examples
The following table shows how example values would be displayed with different formats and locales.
Positive value | Format | Locale | Positive example | Negative example |
---|---|---|---|---|
125.83 | 0 |
English | 126 | -126 |
4.5 | 0.00 |
English | 4.50 | -4.50 |
112.334 | #.####### |
English | 112.334 | -112.334 |
1125638.7 | #,###.### |
English | 1,125,638.7 | -1,125,638.7 |
1125638.7 | #,###.### |
German | 1.125.638,7 | -1.125.638,7 |
0.2 | #% |
English | 20% | -20% |
125.6 | #.##;[-#.##] |
English | 125.6 | [-125.6] |
1251 | 0.00E0 |
English | 1.25E3 | -1.25E3 |
You can try out your format using the preview field on the bottom of the decimal formats-tab in the element formats-dialog.