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

sint.h

Go to the documentation of this file.
00001 #ifndef SINT
00002 #define SINT
00003 #include <int_s.h>
00004 // 
00005 // Copyright(c) 1993-1996 Tony Kirke
00006 // author="Tony Kirke" *
00007 /*
00008  * SPUC - Signal processing using C++ - A DSP library
00009  * 
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014  * 
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00023 */
00024 namespace SPUC {
00027 //
00031 template <long Bits=32> class sint : public int_s
00032 {
00033         public:
00034           sint<Bits>() { 
00035                   bits=Bits-1;
00036                   mask = -1 << bits;
00037           }
00038           sint<Bits>(long y) { 
00039                   q = y;
00040                   bits=Bits-1;
00041                   mask = -1 << bits;
00042           }
00043           inline sint<Bits> operator =(const int_s& y) {   
00044                 q = y.q;
00045                 sign = (y.q & (1 << bits));
00046                 if (  ((mask&q)!=mask) || ((mask&q)!=0) ) {
00047                         q &= ~mask;
00048                         if (sign) q |= mask;
00049                 }
00050        return *this; 
00051           } 
00052           inline sint<Bits> operator =(const long& y) { 
00053                   if (bitpos) {
00054                           if (y) q |= MASK_BIT(bitpos);
00055                           else q &= ~MASK_BIT(bitpos);
00056                           bitpos = 0;
00057                   } else {
00058                         q = y;  
00059                         sign = (y & (1 << bits));
00060                         if (  ((mask&q)!=mask) || ((mask&q)!=0) ) {
00061                         q &= ~mask;
00062                         if (sign) q |= mask;
00063                         }       
00064                   }
00065        return *this; 
00066           } 
00068           inline sint<Bits> operator ()(long i) { 
00069                   bitpos = i;
00070                   return *this;
00071           }
00072 
00073 };
00074 //template <class m, class m1> inline sint<m>::(const sint<m1>& y) : q(y.q) {}
00075 } // namespace SPUC 
00076 #endif

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