Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | 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 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00029 #ifndef __vtkLargeInteger_h
00030 #define __vtkLargeInteger_h
00031 
00032 #include "vtkObject.h"
00033 
00034 class VTK_COMMON_EXPORT vtkLargeInteger 
00035 {
00036 public:
00037   vtkLargeInteger(void);
00038   vtkLargeInteger(long n);
00039   vtkLargeInteger(unsigned long n);
00040   vtkLargeInteger(int n);
00041   vtkLargeInteger(unsigned int n);
00042   vtkLargeInteger(const vtkLargeInteger& n);
00043 #ifdef VTK_SIZEOF_LONG_LONG
00044   vtkLargeInteger(long long n);
00045   vtkLargeInteger(unsigned long long n);
00046 #endif
00047 #if defined( VTK_SIZEOF___INT64 ) && !defined( VTK_SIZEOF_LONG_LONG )
00048   vtkLargeInteger(__int64 n);
00049   vtkLargeInteger(unsigned __int64 n);
00050 #endif
00051   
00052   ~vtkLargeInteger(void);
00053   
00054   char CastToChar(void) const;
00055   short CastToShort(void) const;
00056   int CastToInt(void) const;
00057   long CastToLong(void) const;
00058   unsigned long CastToUnsignedLong(void) const;
00059   
00060   int IsEven(void) const;
00061   int IsOdd(void) const;
00062   int GetLength(void) const; // in bits
00063   int GetBit(unsigned int p) const; // p'th bit (from zero)
00064   int IsZero() const; // is zero
00065   int GetSign(void) const; // is negative
00066   
00067   void Truncate(unsigned int n); // reduce to lower n bits
00068   void Complement(void); // * -1
00069   
00070   int operator==(const vtkLargeInteger& n) const;
00071   int operator!=(const vtkLargeInteger& n) const;
00072   int operator<(const vtkLargeInteger& n) const;
00073   int operator<=(const vtkLargeInteger& n) const;
00074   int operator>(const vtkLargeInteger& n) const;
00075   int operator>=(const vtkLargeInteger& n) const;
00076   
00077   vtkLargeInteger& operator=(const vtkLargeInteger& n);
00078   vtkLargeInteger& operator+=(const vtkLargeInteger& n);
00079   vtkLargeInteger& operator-=(const vtkLargeInteger& n);
00080   vtkLargeInteger& operator<<=(int n);
00081   vtkLargeInteger& operator>>=(int n);
00082   vtkLargeInteger& operator++(void);
00083   vtkLargeInteger& operator--(void);
00084   vtkLargeInteger  operator++(int);
00085   vtkLargeInteger  operator--(int);
00086   vtkLargeInteger& operator*=(const vtkLargeInteger& n);
00087   vtkLargeInteger& operator/=(const vtkLargeInteger& n);
00088   vtkLargeInteger& operator%=(const vtkLargeInteger& n);
00089   // no change of sign for following operators
00090   vtkLargeInteger& operator&=(const vtkLargeInteger& n);
00091   vtkLargeInteger& operator|=(const vtkLargeInteger& n);
00092   vtkLargeInteger& operator^=(const vtkLargeInteger& n);
00093   
00094   vtkLargeInteger operator+(const vtkLargeInteger& n) const;
00095   vtkLargeInteger operator-(const vtkLargeInteger& n) const;
00096   vtkLargeInteger operator*(const vtkLargeInteger& n) const;
00097   vtkLargeInteger operator/(const vtkLargeInteger& n) const;
00098   vtkLargeInteger operator%(const vtkLargeInteger& n) const;
00099   // no change of sign for following operators
00100   vtkLargeInteger operator&(const vtkLargeInteger& n) const;
00101   vtkLargeInteger operator|(const vtkLargeInteger& n) const;
00102   vtkLargeInteger operator^(const vtkLargeInteger& n) const;
00103   vtkLargeInteger operator<<(int n) const;
00104   vtkLargeInteger operator>>(int n) const;
00105   
00106   friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
00107   friend istream& operator>>(istream& s, vtkLargeInteger& n);
00108   
00109 private:
00110   char* Number;
00111   int Negative;
00112   unsigned int Sig;
00113   unsigned int Max;
00114   
00115   // unsigned operators
00116   int IsSmaller(const vtkLargeInteger& n) const; // unsigned
00117   int IsGreater(const vtkLargeInteger& n) const; // unsigned
00118   void Expand(unsigned int n); // ensure n'th bit exits
00119   void Contract(); // remove leading 0s
00120   void Plus(const vtkLargeInteger& n); // unsigned
00121   void Minus(const vtkLargeInteger& n); // unsigned
00122 };
00123 
00124 #endif
00125 
00126