Bitwise Assign

sint2t is signed_int< 64 > on most 32 bit machines.

Contents

And (&=)

sint2t a, b;

for ( unsigned i = 0; i < (2 * UINT_BITS); ++i )
{
  set_bit( a, i, i & 1 );
  set_bit( b, i, ~i & 1 );
}

CHECK( (a & b) == 0 );

a <<= 1;

b &= a;
CHECK( b == a );

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

Ok

Or (|=)

sint2t a, b, c;

for ( unsigned i = 0; i < (2 * UINT_BITS); ++i )
{
  set_bit( a, i, i & 1 );
  set_bit( b, i, ~i & 1 );
}

c = a;
c |= b;
CHECK( c == -1 );

a <<= 1;

c = a;
c |= b;
CHECK( c == b );

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

Ok

Xor (^=)

sint2t a, b, c;

for ( unsigned i = 0; i < (2 * UINT_BITS); ++i )
{
  set_bit( a, i, i & 1 );
  set_bit( b, i, ~i & 1 );
}

c = a;
c ^= b;
CHECK( c == -1 );

a <<= 1;

c = a;
c ^= b;
CHECK( c == 1 );

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

Ok