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  vtkLargeInteger(long long n);
35  vtkLargeInteger(unsigned long long n);
36 
37  ~vtkLargeInteger(void);
38 
39  char CastToChar(void) const;
40  short CastToShort(void) const;
41  int CastToInt(void) const;
42  long CastToLong(void) const;
43  unsigned long CastToUnsignedLong(void) const;
44 
45  int IsEven(void) const;
46  int IsOdd(void) const;
47  int GetLength(void) const; // in bits
48  int GetBit(unsigned int p) const; // p'th bit (from zero)
49  int IsZero() const; // is zero
50  int GetSign(void) const; // is negative
51 
52  void Truncate(unsigned int n); // reduce to lower n bits
53  void Complement(void); // * -1
54 
55  int operator==(const vtkLargeInteger& n) const;
56  int operator!=(const vtkLargeInteger& n) const;
57  int operator<(const vtkLargeInteger& n) const;
58  int operator<=(const vtkLargeInteger& n) const;
59  int operator>(const vtkLargeInteger& n) const;
60  int operator>=(const vtkLargeInteger& n) const;
61 
62  vtkLargeInteger& operator=(const vtkLargeInteger& n);
63  vtkLargeInteger& operator+=(const vtkLargeInteger& n);
64  vtkLargeInteger& operator-=(const vtkLargeInteger& n);
65  vtkLargeInteger& operator<<=(int n);
66  vtkLargeInteger& operator>>=(int n);
67  vtkLargeInteger& operator++(void);
68  vtkLargeInteger& operator--(void);
69  vtkLargeInteger operator++(int);
70  vtkLargeInteger operator--(int);
71  vtkLargeInteger& operator*=(const vtkLargeInteger& n);
72  vtkLargeInteger& operator/=(const vtkLargeInteger& n);
73  vtkLargeInteger& operator%=(const vtkLargeInteger& n);
74  // no change of sign for following operators
75  vtkLargeInteger& operator&=(const vtkLargeInteger& n);
76  vtkLargeInteger& operator|=(const vtkLargeInteger& n);
77  vtkLargeInteger& operator^=(const vtkLargeInteger& n);
78 
83  vtkLargeInteger operator%(const vtkLargeInteger& n) const;
84  // no change of sign for following operators
85  vtkLargeInteger operator&(const vtkLargeInteger& n) const;
86  vtkLargeInteger operator|(const vtkLargeInteger& n) const;
87  vtkLargeInteger operator^(const vtkLargeInteger& n) const;
88  vtkLargeInteger operator<<(int n) const;
89  vtkLargeInteger operator>>(int n) const;
90 
91  friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
92  friend istream& operator>>(istream& s, vtkLargeInteger& n);
93 
94 private:
95  char* Number;
96  int Negative;
97  unsigned int Sig;
98  unsigned int Max;
99 
100  // unsigned operators
101  int IsSmaller(const vtkLargeInteger& n) const; // unsigned
102  int IsGreater(const vtkLargeInteger& n) const; // unsigned
103  void Expand(unsigned int n); // ensure n'th bit exits
104  void Contract(); // remove leading 0s
105  void Plus(const vtkLargeInteger& n); // unsigned
106  void Minus(const vtkLargeInteger& n); // unsigned
107 };
108 
109 #endif
110 
111 
112 // 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