Masked Decimal Conversion

Format

MD [ n [ m ] ] [ , ] [ $ ] [ F ] [ I ] [ Y ] [ intl ] [ - | < | C | D ] [ P ] [ Z ]
[ T ] [ fx ]

The MD code converts numeric input data to a format appropriate for internal storage. If the code includes the $, F, I, or Y option, the conversion is monetary, otherwise it is numeric. The MD code must appear in either an ICONV or an OCONV expression. When converting internal representation of data to external output format, masked decimal conversion inserts the decimal point and other appropriate formats into the data.

Note: If NLS is enabled and either the Numeric or Monetary categories are set to OFF, the MD code behaves as if NLS locales were turned off.

If the value of n is 0, the decimal point does not appear in the output.

The optional m specifies the power of 10 used to scale the input or output data. On input, the decimal point is moved m places to the right before storing. On output, the decimal point is moved m places to the left. For example, if m is 2 in an input conversion and the input data is 123, it would be stored as 12300. If m is 2 in an output conversion and the stored data is 123, it would be output as 1.23. If m is not specified, it is assumed to be the same as n. In both cases, the last required decimal place is rounded off before excess digits are truncated. Zeros are added if not enough decimal places exist in the original expression.

If NLS is enabled and the conversion is monetary, the thousands separator comes from the THOU_SEP field of the Monetary category of the current locale, and the decimal separator comes from the DEC_SEP field. If the conversion is numeric, the thousands separator comes from the THOU_SEP field of the Numeric category, and the decimal separator comes from the DEC_SEP field.

Table 1. Masked decimal conversion
Option Explanation NoteS
,

Specifies that thousands separators be inserted every three digits to the left of the decimal point on output.

 
$

Prefixes a local currency sign to the number before justification. If NLS is enabled, the CURR_SYMBOL of the Monetary category is used.

 
F

Prefixes a franc sign ( F ) to the number before justification. (In all flavors except IN2, you must specify F in the conversion code if you want ICONV to accept the character F as a franc sign.)

 
I

Used with the OCONV function, the international monetary symbol for the locale is used (INTL_CURR_SYMBOL in the Monetary category). Used with the ICONV function, the international monetary symbol for the locale is removed. If NLS is disabled or the Monetary category is turned off, the default symbol is USD.

 
Y

Used with the OCONV function: if NLS is enabled, the yen/yuan character (Unicode 00A5) is used. If NLS is disabled or the Monetary locale category is turned off, the ASCII character xA5 is used.

 
intl

An expression that customizes numeric output according to different international conventions, allowing multibyte characters. The intl expression can specify a prefix, a suffix, and the characters to use as a thousands delimiter and as the decimal delimiter, using the locale definition from the NLS.LC.NUMERIC file. The intl expression has the following syntax:

 
 

[ prefix , thousands , decimal , suffix ]

 
 

The bold brackets are part of the syntax and must be typed. The four elements are positional parameters and must be separated by commas. Each element is optional, but its position must be held by a comma. For example, to specify a suffix only, type [,,,suffix ].

 
  prefix Character string to prefix to the number. If prefix contains spaces, commas, or right square brackets, enclose it in quotation marks.
  thousands Character string that separates thousands. If thousands contains spaces, commas, or right square brackets, enclose it in quotation marks.
  decimal Character string to use as a decimal delimiter. If decimal contains spaces, commas, or right square brackets, enclose it in quotation marks.
  suffix Character string to append to the number. If suffix contains spaces, commas, or right square brackets, enclose it in quotation marks.
-

Specifies that negative data be suffixed with a minus sign and positive data be suffixed with a blank space.

 
<

Specifies that negative data be enclosed in angle brackets for output; positive data is prefixed and suffixed with a blank space.

 
C

Specifies that negative data include a suffixed CR; positive data is suffixed with two blank spaces.

 
D

Specifies that negative data include a suffixed DB; positive data is suffixed with two blank spaces.

 
P

Specifies that no scaling be performed if the input data already contains a decimal point.

 
Z

Specifies that 0 be output as an empty string.

 
T

Specifies that the data be truncated without rounding.

 
 

Used with the ICONV function: if NLS is enabled, the yen/yuan character is removed. If NLS is disabled or the Monetary category is turned off, the ASCII character xA5 is removed.

 

If the conversion is numeric and the ZERO_SUP field is set to 1, leading zeros of numbers between -1 and 1 are suppressed. For example, -0.5 is output as -.5 .

When converting data to internal format, the fx option has the following effect. If the input data has been overlaid on a background field of characters (for example, $###987.65), the fx option is used with ICONV to indicate that the background characters should be ignored during conversion. The f is a one- or two-digit number indicating the maximum number of background characters to be ignored. The x specifies the background character to be ignored. If background characters exist in the input data and you do not use the fx option, the data is considered bad and an empty string results.

When converting data from internal representation to external output format, the fx option causes the external output of the data to overlay a field of background characters. The f is a one- or two-digit number indicating the number of times the background character is to be repeated. The x specifies the character to be used as a background character. If the $ option is used with the fx option, the $ precedes the background characters when the data is output.