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 
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 "vtkObject.h"
00023 
00024 class VTK_COMMON_EXPORT vtkLargeInteger 
00025 {
00026 public:
00027   vtkLargeInteger(void);
00028   vtkLargeInteger(long n);
00029   vtkLargeInteger(unsigned long n);
00030   vtkLargeInteger(int n);
00031   vtkLargeInteger(unsigned int n);
00032   vtkLargeInteger(const vtkLargeInteger& n);
00033 #if defined(VTK_TYPE_USE_LONG_LONG)
00034   vtkLargeInteger(long long n);
00035   vtkLargeInteger(unsigned long long n);
00036 #endif
00037 #if defined(VTK_TYPE_USE___INT64)
00038   vtkLargeInteger(__int64 n);
00039   vtkLargeInteger(unsigned __int64 n);
00040 #endif
00041   
00042   ~vtkLargeInteger(void);
00043   
00044   char CastToChar(void) const;
00045   short CastToShort(void) const;
00046   int CastToInt(void) const;
00047   long CastToLong(void) const;
00048   unsigned long CastToUnsignedLong(void) const;
00049   
00050   int IsEven(void) const;
00051   int IsOdd(void) const;
00052   int GetLength(void) const; // in bits
00053   int GetBit(unsigned int p) const; // p'th bit (from zero)
00054   int IsZero() const; // is zero
00055   int GetSign(void) const; // is negative
00056   
00057   void Truncate(unsigned int n); // reduce to lower n bits
00058   void Complement(void); // * -1
00059   
00060   int operator==(const vtkLargeInteger& n) const;
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   
00067   vtkLargeInteger& operator=(const vtkLargeInteger& n);
00068   vtkLargeInteger& operator+=(const vtkLargeInteger& n);
00069   vtkLargeInteger& operator-=(const vtkLargeInteger& n);
00070   vtkLargeInteger& operator<<=(int n);
00071   vtkLargeInteger& operator>>=(int n);
00072   vtkLargeInteger& operator++(void);
00073   vtkLargeInteger& operator--(void);
00074   vtkLargeInteger  operator++(int);
00075   vtkLargeInteger  operator--(int);
00076   vtkLargeInteger& operator*=(const vtkLargeInteger& n);
00077   vtkLargeInteger& operator/=(const vtkLargeInteger& n);
00078   vtkLargeInteger& operator%=(const vtkLargeInteger& n);
00079   // no change of sign for following operators
00080   vtkLargeInteger& operator&=(const vtkLargeInteger& n);
00081   vtkLargeInteger& operator|=(const vtkLargeInteger& n);
00082   vtkLargeInteger& operator^=(const vtkLargeInteger& n);
00083   
00084   vtkLargeInteger operator+(const vtkLargeInteger& n) const;
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   // no change of sign for following operators
00090   vtkLargeInteger operator&(const vtkLargeInteger& n) const;
00091   vtkLargeInteger operator|(const vtkLargeInteger& n) const;
00092   vtkLargeInteger operator^(const vtkLargeInteger& n) const;
00093   vtkLargeInteger operator<<(int n) const;
00094   vtkLargeInteger operator>>(int n) const;
00095   
00096   friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
00097   friend istream& operator>>(istream& s, vtkLargeInteger& n);
00098   
00099 private:
00100   char* Number;
00101   int Negative;
00102   unsigned int Sig;
00103   unsigned int Max;
00104   
00105   // unsigned operators
00106   int IsSmaller(const vtkLargeInteger& n) const; // unsigned
00107   int IsGreater(const vtkLargeInteger& n) const; // unsigned
00108   void Expand(unsigned int n); // ensure n'th bit exits
00109   void Contract(); // remove leading 0s
00110   void Plus(const vtkLargeInteger& n); // unsigned
00111   void Minus(const vtkLargeInteger& n); // unsigned
00112 };
00113 
00114 #endif
00115 
00116 

Generated on Mon Jan 21 23:07:17 2008 for VTK by  doxygen 1.4.3-20050530