'Round 5 to even, rest to nearest.'

def _round_half_even(self, prec, expdiff, context):

    tmp = Decimal((self._sign, self._int[:prec], (self._exp - expdiff)))
    half = (self._int[prec] == 5)
    if half:
        for digit in self._int[(prec + 1):]:
            if (digit != 0):
                half = 0
                break
    if half:
        if ((self._int[(prec - 1)] & 1) == 0):
            return tmp
    return self._round_half_up(prec, expdiff, context, tmp)
