VTK  9.3.1
vtkLargeInteger.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
8 #ifndef vtkLargeInteger_h
9 #define vtkLargeInteger_h
10 
11 #include "vtkCommonCoreModule.h" // For export macro
12 #include "vtkObject.h"
13 
14 VTK_ABI_NAMESPACE_BEGIN
15 class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkLargeInteger
16 {
17 public:
19  vtkLargeInteger(long n);
20  vtkLargeInteger(unsigned long n);
21  vtkLargeInteger(int n);
22  vtkLargeInteger(unsigned int n);
24  vtkLargeInteger(long long n);
25  vtkLargeInteger(unsigned long long n);
26 
27  ~vtkLargeInteger();
28 
29  char CastToChar() const;
30  short CastToShort() const;
31  int CastToInt() const;
32  long CastToLong() const;
33  unsigned long CastToUnsignedLong() const;
34 
35  int IsEven() const;
36  int IsOdd() const;
37  int GetLength() const; // in bits
38  int GetBit(unsigned int p) const; // p'th bit (from zero)
39  int IsZero() const; // is zero
40  int GetSign() const; // is negative
41 
42  void Truncate(unsigned int n); // reduce to lower n bits
43  void Complement(); // * -1
44 
45  bool operator==(const vtkLargeInteger& n) const;
46  bool operator!=(const vtkLargeInteger& n) const;
47  bool operator<(const vtkLargeInteger& n) const;
48  bool operator<=(const vtkLargeInteger& n) const;
49  bool operator>(const vtkLargeInteger& n) const;
50  bool operator>=(const vtkLargeInteger& n) const;
51 
52  vtkLargeInteger& operator=(const vtkLargeInteger& n);
55  vtkLargeInteger& operator<<=(int n);
56  vtkLargeInteger& operator>>=(int n);
57  vtkLargeInteger& operator++();
58  vtkLargeInteger& operator--();
59  vtkLargeInteger operator++(int);
60  vtkLargeInteger operator--(int);
61  vtkLargeInteger& operator*=(const vtkLargeInteger& n);
62  vtkLargeInteger& operator/=(const vtkLargeInteger& n);
63  vtkLargeInteger& operator%=(const vtkLargeInteger& n);
64  // no change of sign for following operators
65  vtkLargeInteger& operator&=(const vtkLargeInteger& n);
66  vtkLargeInteger& operator|=(const vtkLargeInteger& n);
67  vtkLargeInteger& operator^=(const vtkLargeInteger& n);
68 
73  vtkLargeInteger operator%(const vtkLargeInteger& n) const;
74  // no change of sign for following operators
77  vtkLargeInteger operator^(const vtkLargeInteger& n) const;
78  vtkLargeInteger operator<<(int n) const;
79  vtkLargeInteger operator>>(int n) const;
80 
81  friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
82  friend istream& operator>>(istream& s, vtkLargeInteger& n);
83 
84 private:
85  char* Number;
86  int Negative;
87  unsigned int Sig;
88  unsigned int Max;
89 
90  // unsigned operators
91  bool IsSmaller(const vtkLargeInteger& n) const; // unsigned
92  bool IsGreater(const vtkLargeInteger& n) const; // unsigned
93  void Expand(unsigned int n); // ensure n'th bit exits
94  void Contract(); // remove leading 0s
95  void Plus(const vtkLargeInteger& n); // unsigned
96  void Minus(const vtkLargeInteger& n); // unsigned
97 };
98 
99 VTK_ABI_NAMESPACE_END
100 #endif
101 
102 // VTK-HeaderTest-Exclude: vtkLargeInteger.h
tovtkm::FieldsFlag operator&(const tovtkm::FieldsFlag &a, const tovtkm::FieldsFlag &b)
vtkVector< A, Size > operator+(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
bool VTKCOMMONCORE_EXPORT operator>(const std::string &a, const vtkStringToken &b)
tovtkm::FieldsFlag operator|(const tovtkm::FieldsFlag &a, const tovtkm::FieldsFlag &b)
bool VTKCOMMONCORE_EXPORT operator==(const std::string &a, const vtkStringToken &b)
vtkVector< A, Size > operator/(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
bool VTKCOMMONCORE_EXPORT operator!=(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator<(const std::string &a, const vtkStringToken &b)
vtkVector< A, Size > operator-(const vtkVector< A, Size > &v)
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
vtkVector< T, Size > & operator-=(vtkVector< T, Size > &a, const vtkVector< T, Size > &b)
vtkVector< T, Size > & operator+=(vtkVector< T, Size > &a, const vtkVector< T, Size > &b)
vtkMultiProcessStream & operator>>(vtkMultiProcessStream &stream, T &value)
vtkVector< A, Size > operator*(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
class for arbitrarily large ints
#define VTK_WRAPEXCLUDE
bool VTKCOMMONCORE_EXPORT operator>=(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator<=(const std::string &a, const vtkStringToken &b)