Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

sint.h

Go to the documentation of this file.
00001 // sint header file.
00002 // Contains definition of sint variable class.
00003 
00004 #include <stdinc.h>
00005 //#include <stdio.h>
00006 #include <string.h>
00007 
00008 #define NUMERICAL_PRECISION 16
00009 
00010 class digit_stream;
00011 
00012 class sint {
00013   
00014   protected:
00015 
00016   enum {negative, positive} sign;
00017   
00018     char* digits;
00019     int  ndigits;
00020   
00021     sint(char* d, int n) {
00022       sign = positive; 
00023       digits = d;
00024       ndigits = n;
00025     }
00026     friend digit_stream;
00027 
00028     bool is_negative()  const;    // return true iff number is negative
00029     bool is_positive()  const;    // return true iff number is positive
00030 
00031     bool equal(const sint & rhs)        const;
00032     int NumDigits()     const;    // return # digits in number
00033     int GetDigit(int k) const;
00034     int set_digit(int k) const;
00035 
00036   public:
00037     void chop();
00038 
00039     sint(const char*);
00040     sint(int); 
00041     sint(real); 
00042     sint(const sint&); 
00043     ~sint() {delete digits;}
00044     
00045     void operator = (const sint&);
00046     sint operator + (const sint&);
00047 
00048     bool LessThan(const sint & rhs)     const;
00049     
00050     void print(ostream &s = cerr)       const;
00051     friend ostream & operator <<(ostream &, const sint &);
00052 };
00053 
00054 bool operator <  (const sint & lhs, const sint & rhs);
00055 bool operator >  (const sint & lhs, const sint & rhs);
00056 
00057 class digit_stream {
00058   
00059   protected:
00060   
00061   char* dp;
00062   int nd;
00063   
00064   public:
00065   
00066     digit_stream(const sint& n) {
00067       dp = n.digits;
00068       nd = n.ndigits;
00069     }
00070     int operator ++ () {
00071       if (nd==0) return 0;
00072       else {
00073         nd--;
00074         return *dp++;
00075       }
00076     }
00077 };
00078 

Generated at Sun Feb 24 09:57:16 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001