OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return PlusCompare(a, b, c) == 0; | 85 return PlusCompare(a, b, c) == 0; |
86 } | 86 } |
87 // Returns a + b <= c | 87 // Returns a + b <= c |
88 static bool PlusLessEqual(const Bignum& a, const Bignum& b, const Bignum& c) { | 88 static bool PlusLessEqual(const Bignum& a, const Bignum& b, const Bignum& c) { |
89 return PlusCompare(a, b, c) <= 0; | 89 return PlusCompare(a, b, c) <= 0; |
90 } | 90 } |
91 // Returns a + b < c | 91 // Returns a + b < c |
92 static bool PlusLess(const Bignum& a, const Bignum& b, const Bignum& c) { | 92 static bool PlusLess(const Bignum& a, const Bignum& b, const Bignum& c) { |
93 return PlusCompare(a, b, c) < 0; | 93 return PlusCompare(a, b, c) < 0; |
94 } | 94 } |
| 95 |
95 private: | 96 private: |
96 typedef uint32_t Chunk; | 97 typedef uint32_t Chunk; |
97 typedef uint64_t DoubleChunk; | 98 typedef uint64_t DoubleChunk; |
98 | 99 |
99 static const int kChunkSize = sizeof(Chunk) * 8; | 100 static const int kChunkSize = sizeof(Chunk) * 8; |
100 static const int kDoubleChunkSize = sizeof(DoubleChunk) * 8; | 101 static const int kDoubleChunkSize = sizeof(DoubleChunk) * 8; |
101 // With bigit size of 28 we loose some bits, but a double still fits easily | 102 // With bigit size of 28 we loose some bits, but a double still fits easily |
102 // into two chunks, and more importantly we can use the Comba multiplication. | 103 // into two chunks, and more importantly we can use the Comba multiplication. |
103 static const int kBigitSize = 28; | 104 static const int kBigitSize = 28; |
104 static const Chunk kBigitMask = (1 << kBigitSize) - 1; | 105 static const Chunk kBigitMask = (1 << kBigitSize) - 1; |
(...skipping 26 matching lines...) Expand all Loading... |
131 int used_digits_; | 132 int used_digits_; |
132 // The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize). | 133 // The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize). |
133 int exponent_; | 134 int exponent_; |
134 | 135 |
135 DISALLOW_COPY_AND_ASSIGN(Bignum); | 136 DISALLOW_COPY_AND_ASSIGN(Bignum); |
136 }; | 137 }; |
137 | 138 |
138 } } // namespace v8::internal | 139 } } // namespace v8::internal |
139 | 140 |
140 #endif // V8_BIGNUM_H_ | 141 #endif // V8_BIGNUM_H_ |
OLD | NEW |