This section describes error checking for:
In ILE C, packed decimal is implemented as a native data type. This
allows an error such as invalid decimal format to be detected at compile
time.
In C++, detection of a similar error is deferred until run time, as shown in
the following examples:
#define _DEBUG 1 #include <bcd.h> int main ( void ) { _DecimalT<10,20> b= __D("ABC"); // Run-time exception is raised }
and
#define _DEBUG 1 #include <bcd.h> int main ( void ) { _DecimalT<33,2> a; // Max. dig. allow is 31. Again, // run-time exception is raised }
ILE C provides additional error checking on the sign or the digit codes of the
packed decimal operand. Valid signs are hex A-F. Valid digit
range is hex 0-9. If the decimal operand is in error, ILE C generates
an error message. This additional checking is not present in the
_DecimalT class template.
The following code results in an error message in ILE C but not in ILE
C++:
#include <decimal.h> int main ( void ) { decimal(10,2) a, b; int c; c = a > b; // a and b are not valid packed decimals because // a and b are not initialized }
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.