OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Original code by Matt McCutchen, see the LICENSE file |
| 6 |
1 #ifndef BIGUNSIGNEDINABASE_H | 7 #ifndef BIGUNSIGNEDINABASE_H |
2 #define BIGUNSIGNEDINABASE_H | 8 #define BIGUNSIGNEDINABASE_H |
3 | 9 |
4 #include "NumberlikeArray.hh" | 10 #include "NumberlikeArray.hh" |
5 #include "BigUnsigned.hh" | 11 #include "BigUnsigned.hh" |
6 #include <string> | 12 #include <string> |
7 | 13 |
8 /* | 14 /* |
9 * A BigUnsignedInABase object represents a nonnegative integer of size limited | 15 * A BigUnsignedInABase object represents a nonnegative integer of size limited |
10 * only by available memory, represented in a user-specified base that can fit | 16 * only by available memory, represented in a user-specified base that can fit |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 */ | 99 */ |
94 operator std::string() const; | 100 operator std::string() const; |
95 BigUnsignedInABase(const std::string &s, Base base); | 101 BigUnsignedInABase(const std::string &s, Base base); |
96 | 102 |
97 public: | 103 public: |
98 | 104 |
99 // ACCESSORS | 105 // ACCESSORS |
100 Base getBase() const { return base; } | 106 Base getBase() const { return base; } |
101 | 107 |
102 // Expose these from NumberlikeArray directly. | 108 // Expose these from NumberlikeArray directly. |
103 » NumberlikeArray<Digit>::getCapacity; | 109 » using NumberlikeArray<Digit>::getCapacity; |
104 » NumberlikeArray<Digit>::getLength; | 110 » using NumberlikeArray<Digit>::getLength; |
105 | 111 |
106 /* Returns the requested digit, or 0 if it is beyond the length (as if | 112 /* Returns the requested digit, or 0 if it is beyond the length (as if |
107 * the number had 0s infinitely to the left). */ | 113 * the number had 0s infinitely to the left). */ |
108 Digit getDigit(Index i) const { return i >= len ? 0 : blk[i]; } | 114 Digit getDigit(Index i) const { return i >= len ? 0 : blk[i]; } |
109 | 115 |
110 // The number is zero if and only if the canonical length is zero. | 116 // The number is zero if and only if the canonical length is zero. |
111 bool isZero() const { return NumberlikeArray<Digit>::isEmpty(); } | 117 bool isZero() const { return NumberlikeArray<Digit>::isEmpty(); } |
112 | 118 |
113 /* Equality test. For the purposes of this test, two BigUnsignedInABase | 119 /* Equality test. For the purposes of this test, two BigUnsignedInABase |
114 * values must have the same base to be equal. */ | 120 * values must have the same base to be equal. */ |
115 bool operator ==(const BigUnsignedInABase &x) const { | 121 bool operator ==(const BigUnsignedInABase &x) const { |
116 return base == x.base && NumberlikeArray<Digit>::operator ==(x); | 122 return base == x.base && NumberlikeArray<Digit>::operator ==(x); |
117 } | 123 } |
118 bool operator !=(const BigUnsignedInABase &x) const { return !operator =
=(x); } | 124 bool operator !=(const BigUnsignedInABase &x) const { return !operator =
=(x); } |
119 | 125 |
120 }; | 126 }; |
121 | 127 |
122 #endif | 128 #endif |
OLD | NEW |