00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef UINT
00021 #define UINT
00022 #include <int_u.h>
00023 namespace SPUC {
00026
00030 template <long Bits=32> class uint : public int_u
00031 {
00032 public:
00033 bool overflow;
00034
00035 uint<Bits>() {
00036 bits=Bits;
00037 mask = -1 << Bits;
00038 overflow = 0;
00039 }
00040 uint<Bits>(long y) {
00041 q = y;
00042 bits=Bits;
00043 mask = -1 << Bits;
00044 overflow = 0;
00045 }
00046 inline uint<Bits> operator =(const int_u& y) {
00047 overflow = 0;
00048 q = y.q;
00049 if ( ((mask&q)!=mask) || ((mask&q)!=0) ) {
00050 q &= ~mask;
00051 overflow = 1;
00052 }
00053 return *this;
00054 }
00055 inline uint<Bits> operator =(const long& y) {
00056 overflow = 0;
00057 if (bitpos) {
00058 if (y) q |= MASK_BIT(bitpos);
00059 else q &= ~MASK_BIT(bitpos);
00060 bitpos = 0;
00061 } else {
00062 q = y;
00063 if ( ((mask&q)!=mask) || ((mask&q)!=0) ) {
00064 q &= ~mask;
00065 overflow = 1;
00066 }
00067 }
00068 return *this;
00069 }
00070 inline uint<Bits> operator ()(long i) {
00071 bitpos = i;
00072 return *this;
00073 }
00074 };
00075 }
00076 #endif