simplify (d&a) and (d&~a) calculation, hint by skal