(self, lden, rden)
return lexp, man, neg
Denormalised add.
Denormalised add.
Denormalised add .
def _add_den(self, lden, rden):
        """Denormalised add."""
        lexp, lman, lneg = lden
        rexp, rman, rneg = rden
        if rexp == 0:
            return lexp, lman, lneg
        if lexp == 0:
            return rexp, rman, rneg
        # ensure right is larger
        if lexp > rexp or (lexp == rexp and lman > rman):
            lexp, lman, lneg, rexp, rman, rneg = rexp, rman, rneg, lexp, lman, lneg
        # zero flag for quirky rounding
        # only set if all the bits we lose by matching exponents were zero
        zero_flag = lman & ((1<<(rexp-lexp))-1) == 0
        sub_flag = lneg != rneg
        # match exponents
        lman >>= (rexp - lexp)
        lexp = rexp
        # shortcut (this affects quirky rounding)
        if (lman < 0x80 or lman == 0x80 and zero_flag) and sub_flag:
            return rexp, rman, rneg
        # add mantissas, taking sign into account
        if not sub_flag:
            man, neg = lman + rman, lneg
            if man >= self._den_upper:
                lexp += 1
                man >>= 1
        else:
            man, neg = rman - lman, rneg
        # break tie for rounding if we're at exact half after dropping digits
        if not zero_flag and not sub_flag:
            man |= 0x1
        # attempt to match GW-BASIC subtraction rounding
        if sub_flag and (man & 0x1c0 == 0x80) and (man & 0x1df != 0x80):
            man &= (self._carrymask + 0x7f)
        return lexp, man, neg
def _add_den ( self , lden , rden ) : lexp , lman , lneg = lden rexp , rman , rneg = rden if rexp == 0 : return lexp , lman , lneg if lexp == 0 : return rexp , rman , rneg # ensure right is larger if lexp > rexp or ( lexp == rexp and lman > rman ) : lexp , lman , lneg , rexp , rman , rneg = rexp , rman , rneg , lexp , lman , lneg # zero flag for quirky rounding # only set if all the bits we lose by matching exponents were zero zero_flag = lman & ( ( 1 << ( rexp - lexp ) ) - 1 ) == 0 sub_flag = lneg != rneg # match exponents lman >>= ( rexp - lexp ) lexp = rexp # shortcut (this affects quirky rounding) if ( lman < 0x80 or lman == 0x80 and zero_flag ) and sub_flag : return rexp , rman , rneg # add mantissas, taking sign into account if not sub_flag : man , neg = lman + rman , lneg if man >= self . _den_upper : lexp += 1 man >>= 1 else : man , neg = rman - lman , rneg # break tie for rounding if we're at exact half after dropping digits if not zero_flag and not sub_flag : man |= 0x1 # attempt to match GW-BASIC subtraction rounding if sub_flag and ( man & 0x1c0 == 0x80 ) and ( man & 0x1df != 0x80 ) : man &= ( self . _carrymask + 0x7f ) return lexp , man , neg