VTK  9.7.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);
62  vtkLargeInteger& operator/=(const vtkLargeInteger& n);
63  vtkLargeInteger& operator%=(const vtkLargeInteger& n);
64  // no change of sign for following operators
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
vtkVector< A, Size > operator+(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
Performs addition of vectors of the same basic type.
Definition: vtkVector.h:539
tovtkm::FieldsFlag operator&(const tovtkm::FieldsFlag &a, const tovtkm::FieldsFlag &b)
vtkVector< T, Size > & operator-=(vtkVector< T, Size > &a, const vtkVector< T, Size > &b)
Subtract the vector b to the vector a of the same basic type.
Definition: vtkVector.h:595
vtkCellStatus & operator|=(vtkCellStatus &a, vtkCellStatus b)
Definition: vtkCellStatus.h:66
vtkVector< A, Size > operator*(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
Performs multiplication of vectors of the same basic type.
Definition: vtkVector.h:609
vtkVector< T, Size > & operator+=(vtkVector< T, Size > &a, const vtkVector< T, Size > &b)
Add the vector b to the vector a of the same basic type.
Definition: vtkVector.h:553
bool VTKCOMMONCORE_EXPORT operator>(const std::string &a, const vtkStringToken &b)
tovtkm::FieldsFlag operator|(const tovtkm::FieldsFlag &a, const tovtkm::FieldsFlag &b)
vtkCellStatus & operator&=(vtkCellStatus &a, vtkCellStatus b)
Definition: vtkCellStatus.h:60
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)
Performs division of vectors of the same type.
Definition: vtkVector.h:637
vtkVector< T, Size > & operator*=(vtkVector< T, Size > &a, Scalar f)
Multiply a vector a by a scalar.
Definition: vtkVector.h:567
vtkVector< A, Size > operator-(const vtkVector< A, Size > &v)
This following operators enhance the vtkVector classes, allowing various operator overloads one might...
Definition: vtkVector.h:525
bool VTKCOMMONCORE_EXPORT operator!=(const std::string &a, const vtkStringToken &b)
bool VTKCOMMONCORE_EXPORT operator<(const std::string &a, const vtkStringToken &b)
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
vtkMultiProcessStream & operator>>(vtkMultiProcessStream &stream, T &value)
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)