Declaring fixed-point decimal constants

The syntax for fixed-point decimal constants is shown in Table 1.

Table 1. Declarations of fixed-point decimal constants
Data type Syntax
fixed-point-decimal-constant Use the following format:
  fractional-c	onstant fixed-point-decimal-suffix
fractional-constant Use any one of the following formats:
  digit-sequence . digit-sequence
  . digit-sequence
  digit-sequence .
  digit-sequence
digit-sequence Use any one of the following formats:
  digit
  digit-sequence digit
fixed-point-decimal-suffix Use any one of the following formats:
  D
  d

A fixed-point decimal constant has a numeric part and a suffix that specifies its data type. The components of the numeric part may include a digit sequence representing the integral part, followed by a decimal point (.), followed by a digit sequence representing the fractional part. Either the integral part, the fractional part, or both are present.

Each fixed-point decimal constant has the attributes number of digits (digits) and number of decimal places (precision). Leading or trailing zeros are not discarded when the digits and the precision are determined.

Table 2 gives examples of fixed-point decimal constants and their corresponding attributes:

Table 2. Examples of Fixed-Point decimal constants and their attributes
Fixed-Point Decimal Constant (digits, precision)
1234567890123456D ( 16, 0 )
12345678.12345678D ( 16, 8 )
12345678.d ( 8, 0 )
.1234567890d ( 10, 10 )
12345.99d ( 7, 2 )
000123.990d ( 9, 3 )
0.00D ( 3, 2 )