Patent ID: 7814138

Claim:
A machine-implemented method for performing a decimal number addition between a first operand and a second operand using hardware for binary number operations, comprising: obtaining a first coefficient and a first exponent for said first operand, and a second coefficient and a second exponent for said second operand, said first and second coefficients and said first and second exponents being integer in a binary format; performing a binary multiplication using a binary integer multiplier and a binary addition using a binary integer adder to produce a first result based on said first and second coefficients and said first and second exponents; rounding the number of decimal digits in said first result to a pre-determined number of digits in a designated rounding mode to obtain a second result, including determining the number of decimal digits in said first result, comparing the number of decimal digits of said first result with said pre-determined number of digits, using said first result as said second result, if the number of decimal digits in said first result is less than or equal to said pre-determined number of digits, and otherwise converting said first result to said second result, said converting including calculating a difference (x) between the number of decimal digits in said first result and said pre-determined number of digits, obtaining a binary representation of 10^(−x), if said designated rounding mode is either rounding-down or rounding-up, performing a binary integer multiplication between said first result and said binary representation of 10^(−x) to produce an intermediate result, and if said designed rounding mode is rounding-to-nearest, obtaining a binary representation of (½*10^x), performing a binary addition between said first result and said binary representation of (½*10^x), and performing a binary integer multiplication between the result of said binary addition and said binary representation of 10^(−x) to produce said intermediate result; obtaining a final result for said decimal number addition based at least in part on said second result; and determining whether said final result is exact.