In the class template _DecimalT, neither the constructor nor the assignment operator are overloaded to take any of the class template instantiations from _DecimalT. For this reason, explicit type casting that involves conversion from one _DecimalT class template object to another cannot be done directly. Instead, the macro __D must be used to embrace the expression that requires explicit type casting. This program in the following figure is written in ILE C:
Figure 224. ILE C Code that Uses Packed Decimal Data Types
#include <decimal.h>
void main ()
{
decimal(4,0) d40 = 123D;
decimal(6,0) d60 = d40;
d60 = d40;
decimal(8,0) d80 = (decimal(7,0))1;
decimal(9,0) d90;
d60 = (decimal(7,0))12D;
d60 = (decimal(4,0))d80;
d60 = (decimal(4,0))(d80 + 1);
d60 = (decimal(4,0))(d80 + (float)4.500);
}
|
This source needs to be rewritten in ILE C++ as shown in the following figure:
|
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.