Addition / Subtraction Example

A test case of operator - () and operator + () with real numbers.

unsigned_int< 256 >
  a( "123456789123456789123456789" ),
  b( "234567891234567891234567890" ),
  c,
  r( "358024680358024680358024679" )
;

std::cout << "r: " << r << "\n?: 358024680358024680358024679\n";

c = a + b;
assert( c == r );
assert( ( c - a ) == b );
c -= a;
assert( c == b );
c += a;
assert( c == r );

Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed

Output

r: 358024680358024680358024679
?: 358024680358024680358024679
Ok