An 80-bit value is best kept as a combination of long (for the mantissa) and int for the exponent and sign. For many operations, it will probably be most appropriate to place the upper and lower halves of the length into separate βlongβ values, so the code for adding two numbers with the corresponding signs and indicators is likely to be something like this:
long resultLo = (num1.mant & 0xFFFFFFFFL)+(num2.mant & 0xFFFFFFFFL); long resultHi = (num1.mant >>> 32)+(num2.mant >>> 32)+(resultLo >>> 32); result.exp = num1.exp;
A bit of trouble around, but not completely inoperative. The key is to break the numbers into pieces small enough so that you can do all your math as you type "long".
By the way, note that if one of the numbers initially did not have the same indicator, it will be necessary to monitor whether any bits stopped when moving it left or right to correspond to the indicator of the first number, so that after that properly round the result.
source share