Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkLargeInteger.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkLargeInteger.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00023 #ifndef __vtkLargeInteger_h
00024 #define __vtkLargeInteger_h
00025 
00026 #include "vtkObject.h"
00027 
00028 class VTK_COMMON_EXPORT vtkLargeInteger 
00029 {
00030 public:
00031   vtkLargeInteger(void);
00032   vtkLargeInteger(long n);
00033   vtkLargeInteger(unsigned long n);
00034   vtkLargeInteger(int n);
00035   vtkLargeInteger(unsigned int n);
00036   vtkLargeInteger(const vtkLargeInteger& n);
00037   ~vtkLargeInteger(void);
00038   
00039   char CastToChar(void) const;
00040   short CastToShort(void) const;
00041   int CastToInt(void) const;
00042   long CastToLong(void) const;
00043   unsigned long CastToUnsignedLong(void) const;
00044   
00045   int IsEven(void) const;
00046   int IsOdd(void) const;
00047   int GetLength(void) const; // in bits
00048   int GetBit(unsigned int p) const; // p'th bit (from zero)
00049   int IsZero() const; // is zero
00050   int GetSign(void) const; // is negative
00051   
00052   void Truncate(unsigned int n); // reduce to lower n bits
00053   void Complement(void); // * -1
00054   
00055   int operator==(const vtkLargeInteger& n) const;
00056   int operator!=(const vtkLargeInteger& n) const;
00057   int operator<(const vtkLargeInteger& n) const;
00058   int operator<=(const vtkLargeInteger& n) const;
00059   int operator>(const vtkLargeInteger& n) const;
00060   int operator>=(const vtkLargeInteger& n) const;
00061   
00062   vtkLargeInteger& operator=(const vtkLargeInteger& n);
00063   vtkLargeInteger& operator+=(const vtkLargeInteger& n);
00064   vtkLargeInteger& operator-=(const vtkLargeInteger& n);
00065   vtkLargeInteger& operator<<=(int n);
00066   vtkLargeInteger& operator>>=(int n);
00067   vtkLargeInteger& operator++(void);
00068   vtkLargeInteger& operator--(void);
00069   vtkLargeInteger  operator++(int);
00070   vtkLargeInteger  operator--(int);
00071   vtkLargeInteger& operator*=(const vtkLargeInteger& n);
00072   vtkLargeInteger& operator/=(const vtkLargeInteger& n);
00073   vtkLargeInteger& operator%=(const vtkLargeInteger& n);
00074   // no change of sign for following operators
00075   vtkLargeInteger& operator&=(const vtkLargeInteger& n);
00076   vtkLargeInteger& operator|=(const vtkLargeInteger& n);
00077   vtkLargeInteger& operator^=(const vtkLargeInteger& n);
00078   
00079   vtkLargeInteger operator+(const vtkLargeInteger& n) const;
00080   vtkLargeInteger operator-(const vtkLargeInteger& n) const;
00081   vtkLargeInteger operator*(const vtkLargeInteger& n) const;
00082   vtkLargeInteger operator/(const vtkLargeInteger& n) const;
00083   vtkLargeInteger operator%(const vtkLargeInteger& n) const;
00084   // no change of sign for following operators
00085   vtkLargeInteger operator&(const vtkLargeInteger& n) const;
00086   vtkLargeInteger operator|(const vtkLargeInteger& n) const;
00087   vtkLargeInteger operator^(const vtkLargeInteger& n) const;
00088   vtkLargeInteger operator<<(int n) const;
00089   vtkLargeInteger operator>>(int n) const;
00090   
00091   friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
00092   friend istream& operator>>(istream& s, vtkLargeInteger& n);
00093   
00094 private:
00095   char* Number;
00096   int Negative;
00097   unsigned int Sig;
00098   unsigned int Max;
00099   
00100   // unsigned operators
00101   int IsSmaller(const vtkLargeInteger& n) const; // unsigned
00102   int IsGreater(const vtkLargeInteger& n) const; // unsigned
00103   void Expand(unsigned int n); // ensure n'th bit exits
00104   void Contract(); // remove leading 0s
00105   void Plus(const vtkLargeInteger& n); // unsigned
00106   void Minus(const vtkLargeInteger& n); // unsigned
00107 };
00108 
00109 #endif
00110 
00111