Using the _DecimalT Class Template

When you are working with ILE C++, the _DecimalT class template allows representation of up to 63 significant digits, including integral and fractional parts. The fractional part of a dollar can be represented accurately by two digits following the decimal point.
Note: In IBM® i 7.1 and earlier the largest packed decimal representation is 31 digits.
Note: You do not have to use floating point arithmetic. Floating point is more suitable for scientific and engineering computations, which often use numbers that:
  • Are much larger than the largest packed decimal variable can store
  • Are much smaller than the smallest packed decimal, but do not have enough precision for commercial use

The same declarations and operators that you use on other data types, such as float, can be applied to _DecimalT class templates, with the exception of unions and bitwise operators that do not apply to _DecimalT class templates.

You can:
  • Declare type definitions, arrays, and structures that have _DecimalT class templates.
  • Apply arithmetic, relational, assignment, comma, conditional, equality, logical, and unary operators on the _DecimalT class template.
  • Pass _DecimalT class templates in function calls. The _DecimalT class template is compatible with packed decimal representations in ILE languages.
  • Define macros, and call library functions with _DecimalT class templates.
  • View the _DecimalT class template when you use the ILE system debugger.
    Note: When you view a _DecimalT class template, none of the operators are accessible from the debugger. For information on the ILE system debugger, see Debugging Programs.