This library declares a class-template signed_int< N > in namespace imp:
namespace imp
{
template < unsigned MinBits >
struct signed_int : unsigned_int< MinBits >
{
// *implementation details snipped* ...
};
}
See Also:
imp::unsigned_int< MinBits >
To emulate, as far as possible, an inbuilt signed integral type with a user specified fixed minumum number of bits.
imp::signed_int< 128 > variable;
Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed
Output
Ok
#include <iostream>
#include <ostream>
#include "imp/signed_int.hpp"
unsigned const Bits = 256; // for example.
imp::signed_int< Bits >
default_constructed, // = 0
int_constructed( 2 ),
float_constructed( 2e7 ),
cstr_constructed( "0x123456789ABCDEF" ), // explicit
copy_constructed( int_constructed );
int main()
{
default_constructed = int_constructed * float_constructed;
default_constructed /= copy_constructed;
default_constructed += cstr_constructed;
default_constructed = -default_constructed;
std::cout << default_constructed << std::endl;
}
Test Result: gcc34 Passed, msvc80 Passed, msvc71 Passed
Output
-81985529236486895