Unary Operators

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

Contents

Plus (+)

A do nothing operator.

sint2t a = 100;

CHECK( (+a) == a );

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

Ok

Negation (-)

/** sint2t is signed_int< 64 > on most 32bit machines
*/
sint2t mul =  sint2t( 1 ) << (UINT_BITS - 1);
sint2t a = 100, b = -100;

CHECK( (-a) == b );
CHECK( a == (-b) );
a *= mul;
b *= mul;

CHECK( (-a) == b );
CHECK( a == (-b) );

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

Ok

Increment (++)

Pre-increment and Post-increment (add one) operation's.

sint2t mul =  sint2t( 1 ) << (UINT_BITS - 1);
sint2t a = 400;
  
CHECK( ++a == 401 );
CHECK( a++ == 401 );
CHECK( a == 402 );

a *= mul;
mul = a;

CHECK( ++a == (mul + 1) );
CHECK( a++ == (mul + 1) );
CHECK( a == (mul + 2) );

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

Ok

Decrement (--)

Pre-decrement and Post-decrement (subtract one) operation's.

sint2t mul =  sint2t( 1 ) << (UINT_BITS - 1);
sint2t a = 400;
  
CHECK( --a == 399 );
CHECK( a-- == 399 );
CHECK( a == 398 );

a *= mul;
mul = a;

CHECK_PRINT( --a == (mul - 1), a << " - " << (mul - 1) );
CHECK_PRINT( a-- == (mul - 1), a << " - " << (mul - 1) );
CHECK_PRINT( a == (mul - 2), a << " - " << (mul - 2) );

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

Ok