Output (Transform) number formats

#<width, fracwidth>

#<width, fracwidth, padding>

#<textformats, width, fracwidth>

#<textformats, width, fracwidth, padding>

0width

# can be one of the following characters to define the desired number type.

n: generic number

N: generic number with sign

p: percentage number

P: percentage number with sign

c: currency number

C: currency number with sign

The value range or precision of the number is limited by the operating system. The valid number range is 1.7E ±308 (15 digits).

#<width, fracwidth> — used to format a number that has at most width number of characters and at most, fracwidth characters after the decimal.

width defines the total number of digits to be included in the output string.

If width is a positive number, the output text will be right-aligned with the padding character (if any) on the left.

If width is a negative number, the output text will be left-aligned with the padding character (if any) on the right.

fracwidth defines the number of digits to be displayed to the right of the decimal point.

The number 0 is used to show no decimal point.

The character * is used to show a default of 6 digits to the right of the decimal point.

Examples

n<20,2>

Description — a generic number with a maximum width of 20 characters and 2 digits after the decimal point. The string will be right aligned.

Examples

 “324.5” “ 324.50”

“abcd” “ 0.00”

p<-20, 2>

Description — a number expressed as a percentage with a total width of 20 characters and 2 digits after the decimal point. The string will be left aligned.

Examples

 “0.12abc” “12.00% “

“-43” ”-4300.00% “

c<20, 0>

Description — a number expressed as currency with a total width of 20 characters and no decimal point. The string will be right aligned.

Examples

 “12345.6” “ 12,346”

“-12345.6” “ –12,346”

C<20, 2>

Description — a number expressed as signed currency with a total of 20 characters and 2 digits after the decimal point. The string will be right aligned.

Examples

 “12345.6” “ +12,345.60”

“-12345.6” “ –12,345.60”

“abc” “ +0.00”

“-0.001” “ –0.00”

“-0.00” “ +0.00”

#<width, fracwidth, padding> — used to format a number that will be padded with the padding character, to the specified width, including fracwidth characters after the decimal.

padding defines the character to fill the space if the formatted text is less that the width defined.

Example

P<20, 3, ‘#’>

Description — a number expressed as a signed percentage with a total width of 20 characters, 3 digits after the decimal point and padded with the character ‘#’.

Examples

 “0.12abc” “############+12.0000%”

“-43” “##########-4300.000%”

#<textformats, width, fracwidth> — used to format a number that is extracted from a string using textformats.

textformats specifies how to extract the number from the original index string. See Output text formats.

Example

N<[2], 20, 3>

Description — a signed number with a total width of 20 characters and 3 digits after the decimal point. The number will be extracted starting at the 2nd character in the original string.

Examples

“A12345.6” ” +12345.600”

“-12345.6” “ +12345.600”

“TT9000” “ +0.000”

“—9999” “ –9999.000”

N<[2, ‘^’], 20, 3>

Description — a signed number with a total of 20 characters and 3 digits after the decimal point. The number will be extracted from the 2 element in the string, where the elements are separated by the character ‘^’.

Example

“12345.6^45678.9” “ +45678.900”

#<textformats, width, fracwidth, padding> — used to format a number that is extracted from a string using textformats and padded with the specified character.

This format is a extension of the format #<textformats, width, fracwidth> where the output sting will be padded with the specified character.

0width — used to zero fill a number to the minimum specified width.

Examples

 010

Description — a zero filled number with a total width of 10 characters.

Examples

“123” “0000000123”

“0” “0000000000”

03

Description — a zero filled number with a total width of 3 characters.

Example

“1” “001”

“1234” Example

N<[2], 20, 3>

Description — a signed number with a total width of 20 characters and 3 digits after the decimal point. The number will be extracted starting at the 2nd character in the original string.

Examples

“A12345.6” ” +12345.600”

“-12345.6” “ +12345.600”

“TT9000” “ +0.000”

“—9999” “ –9999.000”

N<[2, ‘^’], 20, 3>

Description — a signed number with a total of 20 characters and 3 digits after the decimal point. The number will be extracted from the 2 element in the string, where the elements are separated by the character ‘^’.

Example

“12345.6^45678.9” “ +45678.900”

#<textformats, width, fracwidth, padding> — used to format a number that is extracted from a string using textformats and padded with the specified character.

This format is a extension of the format #<textformats, width, fracwidth> where the output sting will be padded with the specified character.

0width — used to zero fill a number to the minimum specified width.

Examples

 010

Description — a zero filled number with a total width of 10 characters.

Examples

“123” “0000000123”

“0” “0000000000”

03

Description — a zero filled number with a total width of 3 characters.

Example

“1” “001”

“1234” “1234”

See also:

Output formats