ILE C/C++ Programmer's Guide

Determining the Size of a _DecimalT Class Template

When you use the sizeof operator with _DecimalT, you can find out the total number of bytes occupied by the _DecimalT class template.

Note:
Each _DecimalT class template digit occupies half a byte. Half a byte is used for the sign. The number of bytes used by _DecimalT is the smallest whole number greater than or equal to (n + 1)/2 (for example, sizeof(_DecimalT) = ceil((n + 1)/2)).

Figure 304. Example of Determining the Total Number of Bytes Occupied by a _DecimalT Class Template



int y;
_DecimalT <5, 2> x;
// This would be calculated to be 3 bytes
y =sizeof(x); // (5+1)/2 = 3.


[ Top of Page | Previous Page | Next Page | Table of Contents ]