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 =========================================================================*/
20 #ifndef vtkLargeInteger_h
21 #define vtkLargeInteger_h
22 #ifndef __VTK_WRAP__
23 
24 #include "vtkCommonCoreModule.h" // For export macro
25 #include "vtkObject.h"
26 
27 class VTKCOMMONCORE_EXPORT vtkLargeInteger
28 {
29 public:
31  vtkLargeInteger(long n);
32  vtkLargeInteger(unsigned long n);
34  vtkLargeInteger(unsigned int n);
36  vtkLargeInteger(long long n);
37  vtkLargeInteger(unsigned long long n);
38 
40 
41  char CastToChar(void) const;
42  short CastToShort(void) const;
43  int CastToInt(void) const;
44  long CastToLong(void) const;
45  unsigned long CastToUnsignedLong(void) const;
46 
47  int IsEven(void) const;
48  int IsOdd(void) const;
49  int GetLength(void) const; // in bits
50  int GetBit(unsigned int p) const; // p'th bit (from zero)
51  int IsZero() const; // is zero
52  int GetSign(void) const; // is negative
53 
54  void Truncate(unsigned int n); // reduce to lower n bits
55  void Complement(void); // * -1
56 
57  bool operator==(const vtkLargeInteger& n) const;
58  bool operator!=(const vtkLargeInteger& n) const;
59  bool operator<(const vtkLargeInteger& n) const;
60  bool operator<=(const vtkLargeInteger& n) const;
61  bool operator>(const vtkLargeInteger& n) const;
62  bool operator>=(const vtkLargeInteger& n) const;
63 
76  // no change of sign for following operators
80 
86  // no change of sign for following operators
92 
93  friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
94  friend istream& operator>>(istream& s, vtkLargeInteger& n);
95 
96 private:
97  char* Number;
98  int Negative;
99  unsigned int Sig;
100  unsigned int Max;
101 
102  // unsigned operators
103  bool IsSmaller(const vtkLargeInteger& n) const; // unsigned
104  bool IsGreater(const vtkLargeInteger& n) const; // unsigned
105  void Expand(unsigned int n); // ensure n'th bit exits
106  void Contract(); // remove leading 0s
107  void Plus(const vtkLargeInteger& n); // unsigned
108  void Minus(const vtkLargeInteger& n); // unsigned
109 };
110 
111 #endif
112 #endif
113 
114 
115 // VTK-HeaderTest-Exclude: vtkLargeInteger.h
vtkLargeInteger::operator!=
bool operator!=(const vtkLargeInteger &n) const
vtkLargeInteger::operator++
vtkLargeInteger operator++(int)
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(void)
vtkLargeInteger::operator&
vtkLargeInteger operator&(const vtkLargeInteger &n) const
vtkLargeInteger::~vtkLargeInteger
~vtkLargeInteger(void)
vtkLargeInteger::operator<=
bool operator<=(const vtkLargeInteger &n) const
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(long n)
vtkLargeInteger::operator%
vtkLargeInteger operator%(const vtkLargeInteger &n) const
vtkLargeInteger::Complement
void Complement(void)
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(long long n)
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+
vtkLargeInteger operator+(const vtkLargeInteger &n) const
vtkLargeInteger::operator==
bool operator==(const vtkLargeInteger &n) const
vtkLargeInteger::operator/=
vtkLargeInteger & operator/=(const vtkLargeInteger &n)
vtkLargeInteger::operator<<=
vtkLargeInteger & operator<<=(int n)
vtkLargeInteger::operator>>=
vtkLargeInteger & operator>>=(int n)
vtkLargeInteger::operator^
vtkLargeInteger operator^(const vtkLargeInteger &n) const
vtkLargeInteger::operator|=
vtkLargeInteger & operator|=(const vtkLargeInteger &n)
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(unsigned long long n)
vtkObject.h
vtkLargeInteger::operator>>
friend istream & operator>>(istream &s, vtkLargeInteger &n)
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::GetLength
int GetLength(void) const
vtkLargeInteger::operator<
bool operator<(const vtkLargeInteger &n) const
vtkLargeInteger::IsEven
int IsEven(void) const
vtkLargeInteger::IsZero
int IsZero() const
vtkLargeInteger::CastToUnsignedLong
unsigned long CastToUnsignedLong(void) const
vtkLargeInteger::operator>
bool operator>(const vtkLargeInteger &n) const
vtkLargeInteger::operator=
vtkLargeInteger & operator=(const vtkLargeInteger &n)
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(unsigned int n)
vtkLargeInteger::GetSign
int GetSign(void) const
vtkLargeInteger::operator>=
bool operator>=(const vtkLargeInteger &n) const
vtkLargeInteger
class for arbitrarily large ints
Definition: vtkLargeInteger.h:28
vtkLargeInteger::vtkLargeInteger
vtkLargeInteger(const vtkLargeInteger &n)
vtkLargeInteger::operator^=
vtkLargeInteger & operator^=(const vtkLargeInteger &n)
vtkLargeInteger::operator/
vtkLargeInteger operator/(const vtkLargeInteger &n) const