| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/bignum.h" | 5 #include "src/bignum.h" |
| 6 #include "src/utils.h" | 6 #include "src/utils.h" |
| 7 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 bigits_[i] = 0; | 61 bigits_[i] = 0; |
| 62 } | 62 } |
| 63 used_digits_ = other.used_digits_; | 63 used_digits_ = other.used_digits_; |
| 64 } | 64 } |
| 65 | 65 |
| 66 | 66 |
| 67 static uint64_t ReadUInt64(Vector<const char> buffer, | 67 static uint64_t ReadUInt64(Vector<const char> buffer, |
| 68 int from, | 68 int from, |
| 69 int digits_to_read) { | 69 int digits_to_read) { |
| 70 uint64_t result = 0; | 70 uint64_t result = 0; |
| 71 for (int i = from; i < from + digits_to_read; ++i) { | 71 int to = from + digits_to_read; |
| 72 |
| 73 for (int i = from; i < to; ++i) { |
| 72 int digit = buffer[i] - '0'; | 74 int digit = buffer[i] - '0'; |
| 73 DCHECK(0 <= digit && digit <= 9); | 75 DCHECK(0 <= digit && digit <= 9); |
| 74 result = result * 10 + digit; | 76 result = result * 10 + digit; |
| 75 } | 77 } |
| 76 return result; | 78 return result; |
| 77 } | 79 } |
| 78 | 80 |
| 79 | 81 |
| 80 void Bignum::AssignDecimalString(Vector<const char> value) { | 82 void Bignum::AssignDecimalString(Vector<const char> value) { |
| 81 // 2^64 = 18446744073709551616 > 10^19 | 83 // 2^64 = 18446744073709551616 > 10^19 |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 bigits_[i] = difference & kBigitMask; | 745 bigits_[i] = difference & kBigitMask; |
| 744 borrow = difference >> (kChunkSize - 1); | 746 borrow = difference >> (kChunkSize - 1); |
| 745 } | 747 } |
| 746 Clamp(); | 748 Clamp(); |
| 747 DCHECK(Bignum::Equal(a, *this)); | 749 DCHECK(Bignum::Equal(a, *this)); |
| 748 } | 750 } |
| 749 | 751 |
| 750 | 752 |
| 751 } // namespace internal | 753 } // namespace internal |
| 752 } // namespace v8 | 754 } // namespace v8 |
| OLD | NEW |