Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

uint.h

Go to the documentation of this file.
00001 // Copyright(c) 1993-1996 Tony Kirke
00002 // author="Tony Kirke" *
00003 /*
00004  * SPUC - Signal processing using C++ - A DSP library
00005  * 
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2, or (at your option)
00009  * any later version.
00010  * 
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 } // namespace SPUC 
00076 #endif

Generated on Fri Sep 16 11:02:28 2005 for spuc by  doxygen 1.4.4