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 #ifndef __VTK_WRAP__
23 
24 #include "vtkCommonCoreModule.h" // For export macro
25 #include "vtkObject.h"
26 
27 class VTKCOMMONCORE_EXPORT vtkLargeInteger
28 {
29 public:
30  vtkLargeInteger(void);
31  vtkLargeInteger(long n);
32  vtkLargeInteger(unsigned long n);
33  vtkLargeInteger(int n);
34  vtkLargeInteger(unsigned int n);
36  vtkLargeInteger(long long n);
37  vtkLargeInteger(unsigned long long n);
38 
39  ~vtkLargeInteger(void);
40 
41  char CastToChar(void) const;
42  short CastToShort(void) const;
43  int CastToInt(void) const;
44  long CastToLong(void) const;
45  unsigned long CastToUnsignedLong(void) const;
46 
47  int IsEven(void) const;
48  int IsOdd(void) const;
49  int GetLength(void) const; // in bits
50  int GetBit(unsigned int p) const; // p'th bit (from zero)
51  int IsZero() const; // is zero
52  int GetSign(void) const; // is negative
53 
54  void Truncate(unsigned int n); // reduce to lower n bits
55  void Complement(void); // * -1
56 
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  bool operator>=(const vtkLargeInteger& n) const;
63 
64  vtkLargeInteger& operator=(const vtkLargeInteger& n);
65  vtkLargeInteger& operator+=(const vtkLargeInteger& n);
66  vtkLargeInteger& operator-=(const vtkLargeInteger& n);
67  vtkLargeInteger& operator<<=(int n);
68  vtkLargeInteger& operator>>=(int n);
69  vtkLargeInteger& operator++(void);
70  vtkLargeInteger& operator--(void);
71  vtkLargeInteger operator++(int);
72  vtkLargeInteger operator--(int);
73  vtkLargeInteger& operator*=(const vtkLargeInteger& n);
74  vtkLargeInteger& operator/=(const vtkLargeInteger& n);
75  vtkLargeInteger& operator%=(const vtkLargeInteger& n);
76  // no change of sign for following operators
77  vtkLargeInteger& operator&=(const vtkLargeInteger& n);
78  vtkLargeInteger& operator|=(const vtkLargeInteger& n);
79  vtkLargeInteger& operator^=(const vtkLargeInteger& n);
80 
85  vtkLargeInteger operator%(const vtkLargeInteger& n) const;
86  // no change of sign for following operators
89  vtkLargeInteger operator^(const vtkLargeInteger& n) const;
90  vtkLargeInteger operator<<(int n) const;
91  vtkLargeInteger operator>>(int n) const;
92 
93  friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
94  friend istream& operator>>(istream& s, vtkLargeInteger& n);
95 
96 private:
97  char* Number;
98  int Negative;
99  unsigned int Sig;
100  unsigned int Max;
101 
102  // unsigned operators
103  bool IsSmaller(const vtkLargeInteger& n) const; // unsigned
104  bool IsGreater(const vtkLargeInteger& n) const; // unsigned
105  void Expand(unsigned int n); // ensure n'th bit exits
106  void Contract(); // remove leading 0s
107  void Plus(const vtkLargeInteger& n); // unsigned
108  void Minus(const vtkLargeInteger& n); // unsigned
109 };
110 
111 #endif
112 #endif
113 
114 
115 // VTK-HeaderTest-Exclude: vtkLargeInteger.h
tovtkm::FieldsFlag operator&(const tovtkm::FieldsFlag &a, const tovtkm::FieldsFlag &b)
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)
tovtkm::FieldsFlag operator|(const tovtkm::FieldsFlag &a, const tovtkm::FieldsFlag &b)
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