manual:chapter3:numformatting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
manual:chapter3:numformatting [2017/08/13 05:34]
claudio [The Format String]
manual:chapter3:numformatting [2017/08/13 05:58]
claudio [The Format String]
Line 24: Line 24:
 The format string uses the numeral (#) to represent digits. The simplest format string is ''"#"''. The numeral in this case represents the integer part of the number, and its presence on the format string is mandatory. One symbol represents the entire integer part of the number, as many digits as needed.  The format string uses the numeral (#) to represent digits. The simplest format string is ''"#"''. The numeral in this case represents the integer part of the number, and its presence on the format string is mandatory. One symbol represents the entire integer part of the number, as many digits as needed. 
  
-Other options to format the integer part of the number are as follows:\\ +Other options to format the integer part of the number are as follows: 
-''"+#"'': A preceding ''+'' symbol will force the display of the sign even for positive numbers. The negative sign will always be displayed.\\ + 
-''"S#"'': The uppercase ''S'' preceding the numeral 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 force the sign and add the thousand separator every 4 digits. Valid values for S are 1 through 15, and the separator character used will be as defined by the command ''SETLOCALE''.\\ +''"+#"'': A preceding ''+'' symbol will force the display of the sign even for positive numbers. The negative sign will always be displayed. 
-''#.'': A single trailing dot will display the trailing dot for approximate numbers, while no dot will be shown for exact numbers.\\+ 
 +''"S#"'': The uppercase ''S'' preceding the numeral 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 force the sign and add the thousand separator every 4 digits. Valid values for S are 1 through 15, and the separator character used will be as defined by the command ''SETLOCALE''. 
 + 
 +''"#."'': A single trailing dot will display the trailing dot for approximate numbers, while no dot will be shown for exact numbers. 
 + 
 +To display the fraction part of the number, the string needs to include a decimal dot and at least one # symbol (NOTE: The format string must use a decimal dot, even if the decimal separator set in the Locale is a different character, but the correct character from Locale will be used when displaying numbers). The number of digits desired can be expressed in two different ways, by the number of # symbols, or by including the actual number of digits preceding the #, for example ''"#.####"'' or ''"#.4#"'' will both display numbers with up to 4 decimal figures. 
 + 
 +Various other options are available to format the fractional part of the number: 
 + 
 +''"#.###0"'': Replacing the last # with a zero will append trailing zeros as needed to display the requested number of decimal figures. The zero counts as one additional digit, in this example a total of 4 figures will be displayed. 
 + 
 +''"#.4#0"'': Same as above, after the number of digits, a zero indicates that trailing zeros need to be added. When the number of digits is explicitly given the presence of the zero does not add another digit, in this example a total of 4 will be displayed. 
 + 
 +''"#.###0S4"'': The ''S'' after the number of digits indicates the fractional digit separator needs to be included, in this case with an optional spacing of 4 digits. When no number of digits is included, the default is 3 digits (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."'': The trailing dot will display the dot on approximate numbers. 
 + 
 +A number will be displayed in scientific notation when the exponent letter ''e'' or ''E'' is included in the format string after the fractional part.
  
  • manual/chapter3/numformatting.txt
  • Last modified: 2021/10/05 15:29
  • by jojo1973