ADDED: function mod2d from libtommmath (this % 2^k)