VTK
vtkLargeInteger.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLargeInteger.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
19 #ifndef vtkLargeInteger_h
20 #define vtkLargeInteger_h
21 
22 #include "vtkCommonCoreModule.h" // For export macro
23 #include "vtkObject.h"
24 
26 {
27 public:
30  vtkLargeInteger(unsigned long n);
32  vtkLargeInteger(unsigned int n);
34 #if defined(VTK_TYPE_USE_LONG_LONG)
35  vtkLargeInteger(long long n);
36  vtkLargeInteger(unsigned long long n);
37 #endif
38 #if defined(VTK_TYPE_USE___INT64)
39  vtkLargeInteger(__int64 n);
40  vtkLargeInteger(unsigned __int64 n);
41 #endif
42 
44 
45  char CastToChar(void) const;
46  short CastToShort(void) const;
47  int CastToInt(void) const;
48  long CastToLong(void) const;
49  unsigned long CastToUnsignedLong(void) const;
50 
51  int IsEven(void) const;
52  int IsOdd(void) const;
53  int GetLength(void) const; // in bits
54  int GetBit(unsigned int p) const; // p'th bit (from zero)
55  int IsZero() const; // is zero
56  int GetSign(void) const; // is negative
57 
58  void Truncate(unsigned int n); // reduce to lower n bits
59  void Complement(void); // * -1
60 
61  int operator==(const vtkLargeInteger& n) const;
62  int operator!=(const vtkLargeInteger& n) const;
63  int operator<(const vtkLargeInteger& n) const;
64  int operator<=(const vtkLargeInteger& n) const;
65  int operator>(const vtkLargeInteger& n) const;
66  int operator>=(const vtkLargeInteger& n) const;
67 
80  // no change of sign for following operators
84 
90  // no change of sign for following operators
96 
97  friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
98  friend istream& operator>>(istream& s, vtkLargeInteger& n);
99 
100 private:
101  char* Number;
102  int Negative;
103  unsigned int Sig;
104  unsigned int Max;
105 
106  // unsigned operators
107  int IsSmaller(const vtkLargeInteger& n) const; // unsigned
108  int IsGreater(const vtkLargeInteger& n) const; // unsigned
109  void Expand(unsigned int n); // ensure n'th bit exits
110  void Contract(); // remove leading 0s
111  void Plus(const vtkLargeInteger& n); // unsigned
112  void Minus(const vtkLargeInteger& n); // unsigned
113 };
114 
115 #endif
116 
117 
118 // VTK-HeaderTest-Exclude: vtkLargeInteger.h
vtkLargeInteger::operator++
vtkLargeInteger operator++(int)
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(void)
vtkLargeInteger::operator&
vtkLargeInteger operator&(const vtkLargeInteger &n) const
vtkLargeInteger::~vtkLargeInteger
~vtkLargeInteger(void)
VTKCOMMONCORE_EXPORT
#define VTKCOMMONCORE_EXPORT
Definition: vtkCommonCoreModule.h:15
vtkLargeInteger::operator>=
int operator>=(const vtkLargeInteger &n) const
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(long n)
vtkgl::s
GLdouble s
Definition: vtkgl.h:11594
vtkLargeInteger::operator%
vtkLargeInteger operator%(const vtkLargeInteger &n) const
vtkLargeInteger::Complement
void Complement(void)
vtkgl::n
GLclampd n
Definition: vtkgl.h:14370
vtkLargeInteger::operator%=
vtkLargeInteger & operator%=(const vtkLargeInteger &n)
vtkLargeInteger::CastToShort
short CastToShort(void) const
vtkLargeInteger::Truncate
void Truncate(unsigned int n)
vtkLargeInteger::operator|
vtkLargeInteger operator|(const vtkLargeInteger &n) const
vtkLargeInteger::CastToChar
char CastToChar(void) const
vtkLargeInteger::operator++
vtkLargeInteger & operator++(void)
vtkLargeInteger::CastToLong
long CastToLong(void) const
vtkLargeInteger::operator<<
friend ostream & operator<<(ostream &s, const vtkLargeInteger &n)
vtkLargeInteger::operator*
vtkLargeInteger operator*(const vtkLargeInteger &n) const
vtkLargeInteger::CastToInt
int CastToInt(void) const
vtkLargeInteger::operator+=
vtkLargeInteger & operator+=(const vtkLargeInteger &n)
vtkLargeInteger::operator>>
vtkLargeInteger operator>>(int n) const
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(unsigned long n)
vtkLargeInteger::operator*=
vtkLargeInteger & operator*=(const vtkLargeInteger &n)
vtkLargeInteger::operator<<
vtkLargeInteger operator<<(int n) const
vtkLargeInteger::operator<=
int operator<=(const vtkLargeInteger &n) const
vtkLargeInteger::operator+
vtkLargeInteger operator+(const vtkLargeInteger &n) const
vtkCommonCoreModule.h
vtkLargeInteger::operator/=
vtkLargeInteger & operator/=(const vtkLargeInteger &n)
vtkLargeInteger::operator<<=
vtkLargeInteger & operator<<=(int n)
vtkLargeInteger::operator!=
int operator!=(const vtkLargeInteger &n) const
vtkLargeInteger::operator>>=
vtkLargeInteger & operator>>=(int n)
vtkLargeInteger::operator^
vtkLargeInteger operator^(const vtkLargeInteger &n) const
vtkLargeInteger::operator|=
vtkLargeInteger & operator|=(const vtkLargeInteger &n)
vtkLargeInteger::operator<
int operator<(const vtkLargeInteger &n) const
vtkObject.h
vtkLargeInteger::operator>>
friend istream & operator>>(istream &s, vtkLargeInteger &n)
vtkLargeInteger::operator==
int operator==(const vtkLargeInteger &n) const
vtkLargeInteger::IsOdd
int IsOdd(void) const
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(int n)
vtkLargeInteger::operator--
vtkLargeInteger & operator--(void)
vtkLargeInteger::operator--
vtkLargeInteger operator--(int)
vtkLargeInteger::operator-=
vtkLargeInteger & operator-=(const vtkLargeInteger &n)
vtkLargeInteger::GetBit
int GetBit(unsigned int p) const
vtkLargeInteger::operator&=
vtkLargeInteger & operator&=(const vtkLargeInteger &n)
vtkLargeInteger::operator-
vtkLargeInteger operator-(const vtkLargeInteger &n) const
vtkLargeInteger::operator>
int operator>(const vtkLargeInteger &n) const
vtkLargeInteger::GetLength
int GetLength(void) const
vtkgl::p
GLfloat GLfloat p
Definition: vtkgl.h:15717
vtkLargeInteger::IsEven
int IsEven(void) const
vtkLargeInteger::IsZero
int IsZero() const
vtkLargeInteger::CastToUnsignedLong
unsigned long CastToUnsignedLong(void) const
vtkLargeInteger::operator=
vtkLargeInteger & operator=(const vtkLargeInteger &n)
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(unsigned int n)
vtkLargeInteger::GetSign
int GetSign(void) const
vtkLargeInteger
class for arbitrarily large ints
Definition: vtkLargeInteger.h:26
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(const vtkLargeInteger &n)
vtkLargeInteger::operator^=
vtkLargeInteger & operator^=(const vtkLargeInteger &n)
vtkLargeInteger::operator/
vtkLargeInteger operator/(const vtkLargeInteger &n) const