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