Dw.p Format

Prints variables, possibly with a great range of values, lining up decimal places for values of similar magnitude.

Category: Numeric
Alignment: Right

Syntax

D[w].[p]

Arguments

w

specifies the width of the output field.

Default 12
Range 1–32

p

specifies the significant digits.

Default 3
Range 0–16
Requirement must be less than w

Details

The Dw.p format writes numbers so that the decimal point aligns in groups of values with similar magnitude. Larger values of p print the data values with more precision and potentially more shifts in the decimal point alignment. Smaller values of p print the data values with less precision and a greater chance of decimal point alignment.

Comparisons

  • The BESTw. format writes as many significant digits as possible in the output field, but if the numbers vary in magnitude, the decimal points do not line up.
  • Dw.p writes numbers with the desired precision and more alignment than BESTw.
  • The BESTDw.p format is a combination of the BESTw. format and the Dw.p format in that it formats all numeric data, and it does a better job of aligning decimals than the BESTw. format.
  • The w.d format aligns decimal points, if possible, but it does not necessarily show the same precision for all numbers.

Example

Statements
Results
----+----1----+----2
select put (12345,d10.4);
   12345.0
select put (1234.5,d10.4);
    1234.5
select put (123.45,d10.4);
 123.45000
select put (12.345,d10.4);
  12.34500
select put (1.2345,d10.4);
   1.23450
select put (.12345,d10.4);
   0.12345
Last updated: February 23, 2017