VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/Core/vtkLargeInteger.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkLargeInteger.h
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 =========================================================================*/
00019 #ifndef vtkLargeInteger_h
00020 #define vtkLargeInteger_h
00021 
00022 #include "vtkCommonCoreModule.h" // For export macro
00023 #include "vtkObject.h"
00024 
00025 class VTKCOMMONCORE_EXPORT vtkLargeInteger
00026 {
00027 public:
00028   vtkLargeInteger(void);
00029   vtkLargeInteger(long n);
00030   vtkLargeInteger(unsigned long n);
00031   vtkLargeInteger(int n);
00032   vtkLargeInteger(unsigned int n);
00033   vtkLargeInteger(const vtkLargeInteger& n);
00034 #if defined(VTK_TYPE_USE_LONG_LONG)
00035   vtkLargeInteger(long long n);
00036   vtkLargeInteger(unsigned long long n);
00037 #endif
00038 #if defined(VTK_TYPE_USE___INT64)
00039   vtkLargeInteger(__int64 n);
00040   vtkLargeInteger(unsigned __int64 n);
00041 #endif
00042 
00043   ~vtkLargeInteger(void);
00044 
00045   char CastToChar(void) const;
00046   short CastToShort(void) const;
00047   int CastToInt(void) const;
00048   long CastToLong(void) const;
00049   unsigned long CastToUnsignedLong(void) const;
00050 
00051   int IsEven(void) const;
00052   int IsOdd(void) const;
00053   int GetLength(void) const; // in bits
00054   int GetBit(unsigned int p) const; // p'th bit (from zero)
00055   int IsZero() const; // is zero
00056   int GetSign(void) const; // is negative
00057 
00058   void Truncate(unsigned int n); // reduce to lower n bits
00059   void Complement(void); // * -1
00060 
00061   int operator==(const vtkLargeInteger& n) const;
00062   int operator!=(const vtkLargeInteger& n) const;
00063   int operator<(const vtkLargeInteger& n) const;
00064   int operator<=(const vtkLargeInteger& n) const;
00065   int operator>(const vtkLargeInteger& n) const;
00066   int operator>=(const vtkLargeInteger& n) const;
00067 
00068   vtkLargeInteger& operator=(const vtkLargeInteger& n);
00069   vtkLargeInteger& operator+=(const vtkLargeInteger& n);
00070   vtkLargeInteger& operator-=(const vtkLargeInteger& n);
00071   vtkLargeInteger& operator<<=(int n);
00072   vtkLargeInteger& operator>>=(int n);
00073   vtkLargeInteger& operator++(void);
00074   vtkLargeInteger& operator--(void);
00075   vtkLargeInteger  operator++(int);
00076   vtkLargeInteger  operator--(int);
00077   vtkLargeInteger& operator*=(const vtkLargeInteger& n);
00078   vtkLargeInteger& operator/=(const vtkLargeInteger& n);
00079   vtkLargeInteger& operator%=(const vtkLargeInteger& n);
00080   // no change of sign for following operators
00081   vtkLargeInteger& operator&=(const vtkLargeInteger& n);
00082   vtkLargeInteger& operator|=(const vtkLargeInteger& n);
00083   vtkLargeInteger& operator^=(const vtkLargeInteger& n);
00084 
00085   vtkLargeInteger operator+(const vtkLargeInteger& n) const;
00086   vtkLargeInteger operator-(const vtkLargeInteger& n) const;
00087   vtkLargeInteger operator*(const vtkLargeInteger& n) const;
00088   vtkLargeInteger operator/(const vtkLargeInteger& n) const;
00089   vtkLargeInteger operator%(const vtkLargeInteger& n) const;
00090   // no change of sign for following operators
00091   vtkLargeInteger operator&(const vtkLargeInteger& n) const;
00092   vtkLargeInteger operator|(const vtkLargeInteger& n) const;
00093   vtkLargeInteger operator^(const vtkLargeInteger& n) const;
00094   vtkLargeInteger operator<<(int n) const;
00095   vtkLargeInteger operator>>(int n) const;
00096 
00097   friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
00098   friend istream& operator>>(istream& s, vtkLargeInteger& n);
00099 
00100 private:
00101   char* Number;
00102   int Negative;
00103   unsigned int Sig;
00104   unsigned int Max;
00105 
00106   // unsigned operators
00107   int IsSmaller(const vtkLargeInteger& n) const; // unsigned
00108   int IsGreater(const vtkLargeInteger& n) const; // unsigned
00109   void Expand(unsigned int n); // ensure n'th bit exits
00110   void Contract(); // remove leading 0s
00111   void Plus(const vtkLargeInteger& n); // unsigned
00112   void Minus(const vtkLargeInteger& n); // unsigned
00113 };
00114 
00115 #endif
00116 
00117 
00118 // VTK-HeaderTest-Exclude: vtkLargeInteger.h