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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 return result; | 98 return result; |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 void Bignum::AssignDecimalString(Vector<const char> value) { | 102 void Bignum::AssignDecimalString(Vector<const char> value) { |
103 // 2^64 = 18446744073709551616 > 10^19 | 103 // 2^64 = 18446744073709551616 > 10^19 |
104 const int kMaxUint64DecimalDigits = 19; | 104 const int kMaxUint64DecimalDigits = 19; |
105 Zero(); | 105 Zero(); |
106 int length = value.length(); | 106 int length = value.length(); |
107 int pos = 0; | 107 unsigned int pos = 0; |
108 // Let's just say that each digit needs 4 bits. | 108 // Let's just say that each digit needs 4 bits. |
109 while (length >= kMaxUint64DecimalDigits) { | 109 while (length >= kMaxUint64DecimalDigits) { |
110 uint64_t digits = ReadUInt64(value, pos, kMaxUint64DecimalDigits); | 110 uint64_t digits = ReadUInt64(value, pos, kMaxUint64DecimalDigits); |
111 pos += kMaxUint64DecimalDigits; | 111 pos += kMaxUint64DecimalDigits; |
112 length -= kMaxUint64DecimalDigits; | 112 length -= kMaxUint64DecimalDigits; |
113 MultiplyByPowerOfTen(kMaxUint64DecimalDigits); | 113 MultiplyByPowerOfTen(kMaxUint64DecimalDigits); |
114 AddUInt64(digits); | 114 AddUInt64(digits); |
115 } | 115 } |
116 uint64_t digits = ReadUInt64(value, pos, length); | 116 uint64_t digits = ReadUInt64(value, pos, length); |
117 MultiplyByPowerOfTen(length); | 117 MultiplyByPowerOfTen(length); |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 if (borrow == 0) return; | 757 if (borrow == 0) return; |
758 Chunk difference = bigits_[i] - borrow; | 758 Chunk difference = bigits_[i] - borrow; |
759 bigits_[i] = difference & kBigitMask; | 759 bigits_[i] = difference & kBigitMask; |
760 borrow = difference >> (kChunkSize - 1); | 760 borrow = difference >> (kChunkSize - 1); |
761 } | 761 } |
762 Clamp(); | 762 Clamp(); |
763 } | 763 } |
764 | 764 |
765 | 765 |
766 } // namespace double_conversion | 766 } // namespace double_conversion |
OLD | NEW |