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 "vtkObject.h"
23 
25 {
26 public:
27  vtkLargeInteger(void);
28  vtkLargeInteger(long n);
29  vtkLargeInteger(unsigned long n);
30  vtkLargeInteger(int n);
31  vtkLargeInteger(unsigned int n);
33 #if defined(VTK_TYPE_USE_LONG_LONG)
34  vtkLargeInteger(long long n);
35  vtkLargeInteger(unsigned long long n);
36 #endif
37 #if defined(VTK_TYPE_USE___INT64)
38  vtkLargeInteger(__int64 n);
39  vtkLargeInteger(unsigned __int64 n);
40 #endif
41 
42  ~vtkLargeInteger(void);
43 
44  char CastToChar(void) const;
45  short CastToShort(void) const;
46  int CastToInt(void) const;
47  long CastToLong(void) const;
48  unsigned long CastToUnsignedLong(void) const;
49 
50  int IsEven(void) const;
51  int IsOdd(void) const;
52  int GetLength(void) const; // in bits
53  int GetBit(unsigned int p) const; // p'th bit (from zero)
54  int IsZero() const; // is zero
55  int GetSign(void) const; // is negative
56 
57  void Truncate(unsigned int n); // reduce to lower n bits
58  void Complement(void); // * -1
59 
60  int operator==(const vtkLargeInteger& n) const;
61  int operator!=(const vtkLargeInteger& n) const;
62  int operator<(const vtkLargeInteger& n) const;
63  int operator<=(const vtkLargeInteger& n) const;
64  int operator>(const vtkLargeInteger& n) const;
65  int operator>=(const vtkLargeInteger& n) const;
66 
67  vtkLargeInteger& operator=(const vtkLargeInteger& n);
68  vtkLargeInteger& operator+=(const vtkLargeInteger& n);
69  vtkLargeInteger& operator-=(const vtkLargeInteger& n);
70  vtkLargeInteger& operator<<=(int n);
71  vtkLargeInteger& operator>>=(int n);
72  vtkLargeInteger& operator++(void);
73  vtkLargeInteger& operator--(void);
74  vtkLargeInteger operator++(int);
75  vtkLargeInteger operator--(int);
76  vtkLargeInteger& operator*=(const vtkLargeInteger& n);
77  vtkLargeInteger& operator/=(const vtkLargeInteger& n);
78  vtkLargeInteger& operator%=(const vtkLargeInteger& n);
79  // no change of sign for following operators
80  vtkLargeInteger& operator&=(const vtkLargeInteger& n);
81  vtkLargeInteger& operator|=(const vtkLargeInteger& n);
82  vtkLargeInteger& operator^=(const vtkLargeInteger& n);
83 
86  vtkLargeInteger operator*(const vtkLargeInteger& n) const;
87  vtkLargeInteger operator/(const vtkLargeInteger& n) const;
88  vtkLargeInteger operator%(const vtkLargeInteger& n) const;
89  // no change of sign for following operators
90  vtkLargeInteger operator&(const vtkLargeInteger& n) const;
91  vtkLargeInteger operator|(const vtkLargeInteger& n) const;
92  vtkLargeInteger operator^(const vtkLargeInteger& n) const;
93  vtkLargeInteger operator<<(int n) const;
94  vtkLargeInteger operator>>(int n) const;
95 
96  friend ostream& operator<<(ostream& s, const vtkLargeInteger& n);
97  friend istream& operator>>(istream& s, vtkLargeInteger& n);
98 
99 private:
100  char* Number;
101  int Negative;
102  unsigned int Sig;
103  unsigned int Max;
104 
105  // unsigned operators
106  int IsSmaller(const vtkLargeInteger& n) const; // unsigned
107  int IsGreater(const vtkLargeInteger& n) const; // unsigned
108  void Expand(unsigned int n); // ensure n'th bit exits
109  void Contract(); // remove leading 0s
110  void Plus(const vtkLargeInteger& n); // unsigned
111  void Minus(const vtkLargeInteger& n); // unsigned
112 };
113 
114 #endif
115 
116 
const vtkVector2f operator-(const vtkVector2f &lhs, const vtkVector2f &rhs)
Definition: vtkVector.h:244
VTK_COMMON_EXPORT bool operator==(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTK_COMMON_EXPORT bool operator>(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTK_COMMON_EXPORT bool operator<(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTK_COMMON_EXPORT bool operator>=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
VTK_COMMON_EXPORT bool operator<=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
#define VTK_COMMON_EXPORT
const vtkVector2f operator+(const vtkVector2f &lhs, const vtkVector2f &rhs)
Definition: vtkVector.h:240
VTK_COMMON_EXPORT bool operator!=(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
class for arbitrarily large ints
VTK_COMMON_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)