Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
manual:chapter3:numformatting [2021/10/05 11:47] jojo1973 [Preset formats] |
manual:chapter3:numformatting [2021/10/05 15:29] (current) jojo1973 [Format localization] |
"#.12#." @ Normal | "#.12#." @ Normal |
1E-12 "#.12#.E*" @ Small numbers (< 1E-12) | 1E-12 "#.12#.E*" @ Small numbers (< 1E-12) |
1E+12 "#.12#.E*" @ Large numbers (> 1E+12) | 1E12 "#.12#.E*" @ Large numbers (> 1E+12) |
} | } |
</code> | </code> |
Various other options are available to format the fractional part of the number: | Various other options are available to format the fractional part of the number: |
| |
* when the number of decimal digits is expressed by a repetition of ''#'''s, replacing the last ''#'' with a ''0'' will append trailing zeros as needed to display the requested number of decimal figures. The ''0'' character counts as one additional digit. | * when the number of decimal digits is expressed by a repetition of ''#'''s, replacing the last ''#'' with a ''0'' will append as many trailing zeros as needed to display the requested number of decimal figures. The ''0'' character counts as one additional digit. |
* when the number of decimal digits is expressed by a number //d// followed by a ''#'', a trailing ''0'' still indicates that trailing zeros need to be added **but** in this case the presence of ''0'' does not add another digit. | * when the number of decimal digits is expressed by a number //d// followed by a ''#'', a trailing ''0'' still indicates that trailing zeros need to be added **but** in this case the presence of ''0'' does not add another digit. |
* the uppercase ''S'' following the last ''#'' or ''0'' indicates the presence of a separator. By default the separator is spaced every 3 digits, but that can be controlled by including the number of digits in each group immediately following the ''S''; for example ''"S4"'' will add the fractional separator every 4 digits. Valid values for ''S'' are ''1'' through ''15'', and the separator character used will be as defined by the command ''[[manual:chapter6:flags:cmd_setlocale|SETLOCALE]]''.\\ **NOTE**: the number of digits in a group must match between the integer and fractional part of the number, it's an invalid format string to request separators every //n// digits on the integer part, and //m// digits on the fractional part when //m≠n//. | * the uppercase ''S'' following the last ''#'' or ''0'' indicates the presence of a separator. By default the separator is spaced every 3 digits, but that can be controlled by including the number of digits in each group immediately following the ''S''; for example ''"S4"'' will add the fractional separator every 4 digits. Valid values for ''S'' are ''1'' through ''15'', and the separator character used will be as defined by the command ''[[manual:chapter6:flags:cmd_setlocale|SETLOCALE]]''.\\ **NOTE**: the number of digits in a group must match between the integer and fractional part of the number, it's an invalid format string to request separators every //n// digits on the integer part, and //m// digits on the fractional part when //m≠n//. |
| ''#.###0'' | 123.45 | ''123.4500'' | | | ''#.###0'' | 123.45 | ''123.4500'' | |
| ''#.4#0'' | 123.45 | ''123.4500'' | | | ''#.4#0'' | 123.45 | ''123.4500'' | |
| ''#.8#0S4'' | 123.45. | ''123.4500 0000.'' | | | ''#.8#0S4'' | 123.45 | ''123.4500 0000'' | |
| |
---- | ---- |
| **2** | **U**+2009\\ (thin space) | Integer separator | This is the character used to divide the digits groups in the integer part of a number. | | | **2** | **U**+2009\\ (thin space) | Integer separator | This is the character used to divide the digits groups in the integer part of a number. | |
| **3** | **U**+2009\\ (thin space) | Fractional separator | This is the character used to divide the digits groups in the fractional part of a number. | | | **3** | **U**+2009\\ (thin space) | Fractional separator | This is the character used to divide the digits groups in the fractional part of a number. | |
| **4** | '','' | Arguments separator | This is the character used to divide the arguments of a symbolic function or the real and imaginary parts of a complex number. | | | **4** | '','' | Arguments separator | This is the character used to divide the arguments of a symbolic function (e.g. ''%%'%%GCD(16,32)%%'%%'') or the real and imaginary parts of a complex number (e.g. ''(1,-2)''). | |
| |
The ''[[manual:chapter6:flags:cmd_getlocale|GETLOCALE]]'' returns on the stack the localization string. | The ''[[manual:chapter6:flags:cmd_getlocale|GETLOCALE]]'' command returns on the stack the localization string. |
| |
---- | ---- |