defineNumberFormat

defineNumberFormat(numberOfDecimalPlaces: Integer;
                   decimalSep:            String;
                   thousandSep:           String;
                   negFormat:             Integer;
                   showLeadingZero:       Boolean) updating;

The defineNumberFormat method of the NumberFormat class enables you to dynamically define the characteristics of a number format. Set the numberOfDecimalPlaces parameter to the number of decimal places that you want displayed, in the range 0 through 9. A value of zero (0) is assumed if you specify a value less than 0. Conversely, a value of 9 is assumed if you specify a value greater than 9.

The decimalSep and thousandSep parameters enable you to specify a string of up to three characters that is to separate decimals from the rest of the number and to separate thousands, respectively. If the strings contain any numeric characters, these numeric characters are removed. If the strings are longer than three characters, they are truncated to three characters.

If you do not specify one of the NumberFormat class constants listed in the following table, NumberFormat.NegNumLeadingSign is assumed.

NumberFormat Class Constant Integer Value Example
NegNumBrackets 0 (10.25)
NegNumLeadingSign 1 -10.25
NegNumLeadingSignSpace 2 - 10.25 (note the space after -)
NegNumTrailingSign 3 10.25-
NegNumTrailingSpaceSign 4 10.25 - (note the space before -)

Set the showLeadingZero parameter to true if you want to display a leading zero (0) for numbers in the range 1 through -1. Alternatively, set the parameter to false if you do not want to display a leading zero. (For details about returning a string containing the receiver in the supplied number format, see the userNumberFormat method in the Integer, Real, or Decimal primitive type.)