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 
23 #include "vtkCommonCoreModule.h" // For export macro
24 #include "vtkObject.h"
25 
26 class VTKCOMMONCORE_EXPORT vtkLargeInteger
27 {
28 public:
29  vtkLargeInteger(void);
30  vtkLargeInteger(long n);
31  vtkLargeInteger(unsigned long n);
32  vtkLargeInteger(int n);
33  vtkLargeInteger(unsigned int n);
35  vtkLargeInteger(long long n);
36  vtkLargeInteger(unsigned long long n);
37 
38  ~vtkLargeInteger(void);
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 
63  vtkLargeInteger& operator=(const vtkLargeInteger& n);
64  vtkLargeInteger& operator+=(const vtkLargeInteger& n);
65  vtkLargeInteger& operator-=(const vtkLargeInteger& n);
66  vtkLargeInteger& operator<<=(int n);
67  vtkLargeInteger& operator>>=(int n);
68  vtkLargeInteger& operator++(void);
69  vtkLargeInteger& operator--(void);
70  vtkLargeInteger operator++(int);
71  vtkLargeInteger operator--(int);
72  vtkLargeInteger& operator*=(const vtkLargeInteger& n);
73  vtkLargeInteger& operator/=(const vtkLargeInteger& n);
74  vtkLargeInteger& operator%=(const vtkLargeInteger& n);
75  // no change of sign for following operators
76  vtkLargeInteger& operator&=(const vtkLargeInteger& n);
77  vtkLargeInteger& operator|=(const vtkLargeInteger& n);
78  vtkLargeInteger& operator^=(const vtkLargeInteger& n);
79 
84  vtkLargeInteger operator%(const vtkLargeInteger& n) const;
85  // no change of sign for following operators
86  vtkLargeInteger operator&(const vtkLargeInteger& n) const;
87  vtkLargeInteger operator|(const vtkLargeInteger& n) const;
88  vtkLargeInteger operator^(const vtkLargeInteger& n) const;
89  vtkLargeInteger operator<<(int n) const;
90  vtkLargeInteger operator>>(int n) const;
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 
113 // 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)
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