The IBinaryCodedDecimal class defines a set of operators with the same precedence as the corresponding real operators. With these operators, you can code expressions on IBinaryCodedDecimal objects such as the expressions shown in the example below:
IBinaryCodedDecimal value1("123.78");
IBinaryCodedDecimal value2("345.12");
IBinaryCodedDecimal value3("77.457");
IBinaryCodedDecimal Sum, Average;
Sum = value1 + value2; Sum += Sum + value3; // Sum should have value 546.357 Average = Sum / 3; // Average should have value 182.119
The IDecimalDataError exception class is thrown whenever the integral part is truncated as the result of any mathematical operation.
You can use the relational operators < > <= >= for IBinaryCodedDecimal objects and compare IBinaryCodedDecimal objects with other arithmetic types (integer, float, double, and long double):
IBinaryCodedDecimal BCD_1(15); IBinaryCodedDecimal BCD_2(-15);
if (BCD_1 < BCD_2) ...
You can use equality operators with IBinaryCodedDecimal objects to compare IBinaryCodedDecimal objects for equality:
IBinaryCodedDecimal BCD_1(15); IBinaryCodedDecimal BCD_2(-15);
if ( BCD_1 != BCD_2 ) ...
![]()
Representing Numerical
Quantities Using IBinaryCodedDecimal
Assigning One
IBinaryCodedDecimal to Another
Assigning an
IBinaryCodedDecimal to an Integer
Assigning an
IBinaryCodedDecimal to a Float
![]()
What Is a
Binary Coded Decimal