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:
28  vtkLargeInteger(void);
29  vtkLargeInteger(long n);
30  vtkLargeInteger(unsigned long n);
31  vtkLargeInteger(int 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 
43  ~vtkLargeInteger(void);
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 
68  vtkLargeInteger& operator=(const vtkLargeInteger& n);
69  vtkLargeInteger& operator+=(const vtkLargeInteger& n);
70  vtkLargeInteger& operator-=(const vtkLargeInteger& n);
71  vtkLargeInteger& operator<<=(int n);
72  vtkLargeInteger& operator>>=(int n);
73  vtkLargeInteger& operator++(void);
74  vtkLargeInteger& operator--(void);
75  vtkLargeInteger operator++(int);
76  vtkLargeInteger operator--(int);
77  vtkLargeInteger& operator*=(const vtkLargeInteger& n);
78  vtkLargeInteger& operator/=(const vtkLargeInteger& n);
79  vtkLargeInteger& operator%=(const vtkLargeInteger& n);
80  // no change of sign for following operators
81  vtkLargeInteger& operator&=(const vtkLargeInteger& n);
82  vtkLargeInteger& operator|=(const vtkLargeInteger& n);
83  vtkLargeInteger& operator^=(const vtkLargeInteger& n);
84 
89  vtkLargeInteger operator%(const vtkLargeInteger& n) const;
90  // no change of sign for following operators
91  vtkLargeInteger operator&(const vtkLargeInteger& n) const;
92  vtkLargeInteger operator|(const vtkLargeInteger& n) const;
93  vtkLargeInteger operator^(const vtkLargeInteger& n) const;
94  vtkLargeInteger operator<<(int n) const;
95  vtkLargeInteger operator>>(int n) const;
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
VTKCOMMONCORE_EXPORT bool operator>=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTKCOMMONCORE_EXPORT bool operator<=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
#define VTKCOMMONCORE_EXPORT
vtkVector< A, Size > operator+(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
VTKCOMMONCORE_EXPORT bool operator<(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTKCOMMONCORE_EXPORT bool operator>(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkVector< A, Size > operator/(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
vtkVector< A, Size > operator-(const vtkVector< A, Size > &v)
VTKCOMMONCORE_EXPORT bool operator!=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
VTKCOMMONCORE_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkVector< A, Size > operator*(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
class for arbitrarily large ints