bitcoin/bitcoin — Issue #616: base_uint::operator&=(uint64 b)
Author: xanatos
Created: 2011-11-08 14:32:10+00:00
State: open

uint256.h

base_uint& operator&=(uint64 b)
{
pn[0] &= (unsigned int)b;
pn[1] &= (unsigned int)(b >> 32);
return *this;
}

I think this code is conceptually wrong if connected to the operator &=. It's good enough to be put in a separate function. The problem is that it's doing the "logical and" only on the first two uint. The other uint should be zeroed. For example the base_uint::operator==(const base_uint& a, uint64 b) do checks the other uint of the base_uint for 0. This problem isn't present with the ^= and the |= operators because anything ^ 0 = anything, and anything | 0 = anything.