Examples

The following figures show the source to code a packed decimal data type in ILE C and ILE C++:
Figure 1. ILE C Source Code to Port Code to a Packed Decimal Data Type
// ILE C program

#include <decimal.h>

void main()
{
   int dig, prec;
   decimal(9,3) d93;
   dig = digitsof(d93);
   prec = precisionof(d93);
}
Figure 2. ILE C++ Source Code to Port Code a Packed Decimal Data Type
// C++ program

#include <bcd.h>

void main()
{
   int dig, prec;
   _DecimalT<9,3> d93;
   dig = d93.DigitsOf();
   prec = d93.PrecisionOf();
}
The following figure shows you that by using the macros defined in <bcd.h>, you can use the same ILE C shown in the first program:
Figure 3. Example of Using BCD Macros to Port Code to ILE C++
// C++ program using the macro

#include <decimal.h>

void main()
{
   int dig, prec;
   decimal(9,3) d93;
   dig = digitsof(d93);
   prec = precisionof(d93);
}
Note: The <decimal.h> header file is specified because <decimal.h> includes the <bcd.h> header file.