Numeric formats

You can format numeric values in a predefined format or in a format that you define.

The formats featured in this topic only apply to these GainSeeker modules:

The formats used for the Dynamic Reports and GainSeeker Charts version 8.2 and later modules are likely to differ from those featured in this topic. See Numeric formats for information applicable to these modules.

Predefined (standard) numeric formats

The following table identifies the predefined numeric format names:

Format name

Description

General Number

Display number with no digit grouping symbol.

Currency

Display number with currency symbol.  Display digit grouping symbol, if appropriate, and display two digits to the right of the decimal symbol. Output is based on the workstation's regional options.

Fixed

Display at least one digit to the left and two digits to the right of the decimal symbol.

Standard

Display number with digit grouping symbol and at least one digit to the left and two digits to the right of the decimal symbol.

Percent

Display number multiplied by 100 with a percent sign (%) appended to the right; always display two digits to the right of the decimal symbol.

Scientific

Use standard scientific notation.

Yes/No

Display No if number is 0; otherwise, display Yes.

True/False

Display False if number is 0; otherwise, display True.

On/Off

Display Off if number is 0; otherwise, display On.

User-defined (custom) numeric formats

The following table identifies characters you can use to create user-defined number formats:

Character

Description

None

Display the number with no formatting.

(0)

Digit placeholder. Display a digit or a zero. If the expression has a digit in the position where the 0 appears in the format string, display it; otherwise, display a zero in that position. If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, display leading or trailing zeros. If the number has more digits to the right of the decimal symbol than there are zeros to the right of the decimal symbol in the format expression, round the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal symbol than there are zeros to the left of the decimal symbol in the format expression, display the extra digits without modification.

(#)

Digit placeholder. Display a digit or nothing. If the expression has a digit in the position where the # appears in the format string, display it; otherwise, display nothing in that position. This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has the same or fewer digits than there are # characters on either side of the decimal symbol in the format expression.

(.)

Decimal placeholder. The decimal placeholder determines how many digits are displayed to the left and right of the decimal symbol. If the format expression contains only number signs to the left of this symbol, numbers smaller than 1 begin with a decimal symbol. To display a leading zero displayed with fractional numbers, use 0 as the first digit placeholder to the left of the decimal symbol.

The actual character used as a decimal placeholder in the formatted output depends on the decimal symbol in the workstation's regional options.

(%)

Percentage placeholder. The expression is multiplied by 100. The percent character (%) is inserted in the position where it appears in the format string.

(,)

Digit grouping placeholder. The digit grouping symbol separates thousands from hundreds within a number that has four or more places to the left of the decimal symbol. Standard use of the digit grouping symbol is specified if the format contains a digit grouping symbol surrounded by digit placeholders (0 or #). Two adjacent digit grouping symbols or a digit grouping symbol immediately to the left of the decimal symbol (whether or not a decimal is specified) means "scale the number by dividing it by 1000, rounding as needed." For example, you can use the format string "##0,," to represent 100 million as 100. Numbers smaller than 1 million are displayed as 0. Two adjacent digit grouping symbols in any position other than immediately to the left of the decimal symbol are treated simply as specifying the use of a digit grouping symbol.

The actual character used as the digit grouping placeholder in the formatted output depends on the digit grouping symbol in the workstation's regional options.

(:)

Time separator. The time separator separates hours, minutes, and seconds when time values are formatted.

The actual character used as the time separator in formatted output is determined by the time separator in the workstation's regional options.

(/)

Date separator. The date separator separates the day, month, and year when date values are formatted.

The actual character used as the date separator in formatted output is determined by the date separator in the workstation's regional options.

( E- E+ e- e+)

Scientific format. If the format expression contains at least one digit placeholder (0 or #) to the right of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the right determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents.

- + $ ( )

Display the minus sign (-), plus sign (+), dollar sign ($) or space ( ).  

To display any other character, you must precede it with a backslash (\) or enclose it in double quotation marks (" ").  See below for details.

(\)

Display the next character in the format string. To display a character that has special meaning as a literal character, precede it with a backslash (\). The backslash itself isn't displayed. Using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (\\). Examples of characters that can't be displayed as literal characters are the date-formatting and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, / and :), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !).

("ABC")

Display the string inside the double quotation marks (" "). To include a string in format from within code, you must use Chr(34) to enclose the text (34 is the character code for a quotation mark (")).

A user-defined format expression for numbers can have from one to four sections separated by semicolons. If the format argument contains one of the named numeric formats, only one section is allowed.

If you use...

The result is...

One section only

The format expression applies to all values.

Two sections

The first section applies to positive values and zeros, the second to negative values.

Three sections

The first section applies to positive values, the second to negative values, and the third to zeros.

Four sections

The first section applies to positive values, the second to negative values, the third to zeros, and the fourth to Null values.

The following example has two sections: the first defines the format for positive values and zeros; the second section defines the format for negative values.

"$#,##0;($#,##0)"

If you include semicolons with nothing between them, the missing section is printed using the format of the positive value. For example, the following format displays positive and negative values using the format in the first section and displays "Zero" if the value is zero.

"$#,##0;;\ Z\e\r\o"

 

More:

Numeric format examples