A script-enabled browser is required for this page to function properly.

Specifying number format masks

The following table describes the tokens you can use in creating a number format mask:

Format Token

Explanation

0

Prints one digit.

N

Prints one digit, unless it is a leading zero to the left of the decimal point or a trailing zero to the right of the decimal point.

*

Prints one digit, unless it is a leading zero to the left of the decimal point, in which case an asterisk (*) is printed. Trailing zeros to the right of the decimal point are printed.

9

Prints one digit, unless it is a leading zero to the left of the decimal point, in which case a space is printed. Trailing zeros to the right of the decimal point are printed.

+

Prints a leading plus (+) for positive values and a leading minus (-) for negative values. This token must lead the mask.

-

Prints a leading minus (-) for negative values and nothing for positive values. This token must lead the other tokens.

MI

Prints a minus (-) after negative values and a space after positive values. This token must trail the other tokens.

S

Prints a minus (-) for negative values and a plus (+) for positive values (wherever the S appears in the mask). This token must lead or trail the other tokens.

PR

Prints angle brackets (<>) around negative values and spaces around positive values. This token must trail the other tokens.

( )

Prints parentheses around negative values and spaces around positive values. The parentheses must surround the other tokens.

DB

Prints a "DB" after positive values. This token must trail the other tokens.

CR

Prints a "CR" after negative values. This token must trail the other tokens.

Y

Causes no sign symbol to be printed for negative or positive values.

V

Causes the number to be multiplied by 10N, where N is the number of 0, 9, *, and S tokens that appear to the right of the V.

EEEE

Causes the number to be printed in scientific notation. All digit tokens refer to digits of the mantissa. There must be exactly one digit to the left of the decimal point (displayed or implicit). The token EEEE prints as E followed by a plus (+), if the ordinate is positive or zero, and a minus (-), if the ordinate is negative, and two digits representing the ordinate (for example, E-99).

"string"

Prints the string between the double quotes. To have double-quotes inside the string, type double-quotes back to back ("").

. (period)

Prints a period (.) to separate the integral and fractional parts of a number.

D

Prints the local decimal character to separate the integral and fractional parts of a number.

, (comma)

Prints a comma (,) as the group/thousands separator.

G

Prints the local group/thousands separator.

$

Prints $.

L

Prints the local currency symbol.

C

Prints the ISO currency symbol.

%

Prints %.

" "

Prints a blank space. (Do not include quotes in mask.)

v

Prints a blank space for all zero values, regardless of other tokens.

K

Prints a blank space.

<>

Delineates the beginning and ending of the decimal-aligned region (that is, that part of the number that you want aligned with the decimal point in the format mask). Angle brackets indicate that the number should always occupy the same amount of space. If necessary, values are padded with blanks to the left or right of the decimal point.

Note: this is ignored in HTML files or when using proportional fonts.

RN, rn

Prints values in uppercase or lowercase Roman numerals, respectively. You cannot enter any other tokens with this token.

Restrictions

Example

Sample Number Format

Number

Number Displayed

-0000

7934

"7934"

 

-7934

"-7934"

-00000

7934

"07934"

-NNNN

7639

"7639"

 

535

"535"

-NNN

7639

"****"

-****

7902

"7902"

-*****

7902

"*7902"

+NNNN

100

"+100"

 

-99

"-99"

(NNNN)

1600

" 1600 "

 

-800

"(800)"

NNNNPR

1600

" 1600 " 

 

-800

"<800>"

NNNNMI

1600

"1600 "

 

-800

"800-"

NNNVNN

343

"34300"

N.NNEEEE

7369

"7.37E+03"

"SRW"-0000

7782

"SRW7782"

-$NNNN.NN

800

"$800"

 

1600

"$1600"

-%NNN

10

"%10"

-NN NNN.NN

3000

"3 000"

+KKNNNNN.00

1950

"+ 1950.00"

 

900

"+ 900.00"

$<NNNNN.00>

1200

"$ 1200.00"

 

500

"$ 500.00"

$<NNNNN.00> DB

1200

"$ 1200.00 DB"

 

-500

"$ 500.00"

$<NNNNN.00> CR

1200

"$ 1200.00"

 

-500

"$ 500.00 CR"

* The quotation marks will not appear in your output. They are used here to make it clear where there are leading or trailing spaces.

See also

Applying a format mask to a numeric object

Specifying date and time format masks