| OLD | NEW |
| 1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 Google Inc. All Rights Reserved. |
| 2 | 2 |
| 3 #include "vm/bigint_operations.h" | 3 #include "vm/bigint_operations.h" |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "platform/utils.h" | 6 #include "platform/utils.h" |
| 7 | 7 |
| 8 #include "vm/double_internals.h" | 8 #include "vm/double_internals.h" |
| 9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 uint32_t value = 0; | 697 uint32_t value = 0; |
| 698 for (intptr_t i = bigint.Length() - 1; i >= 0; i--) { | 698 for (intptr_t i = bigint.Length() - 1; i >= 0; i--) { |
| 699 value <<= kDigitBitSize; | 699 value <<= kDigitBitSize; |
| 700 value += static_cast<uint32_t>(bigint.GetChunkAt(i)); | 700 value += static_cast<uint32_t>(bigint.GetChunkAt(i)); |
| 701 } | 701 } |
| 702 return value; | 702 return value; |
| 703 } | 703 } |
| 704 | 704 |
| 705 | 705 |
| 706 bool BigintOperations::AbsFitsIntoUint64(const Bigint& bigint) { | 706 bool BigintOperations::AbsFitsIntoUint64(const Bigint& bigint) { |
| 707 if (bigint.IsZero()) { |
| 708 return true; |
| 709 } |
| 707 intptr_t b_length = bigint.Length(); | 710 intptr_t b_length = bigint.Length(); |
| 708 intptr_t num_bits = CountBits(bigint.GetChunkAt(b_length - 1)); | 711 intptr_t num_bits = CountBits(bigint.GetChunkAt(b_length - 1)); |
| 709 num_bits += (kDigitBitSize * (b_length - 1)); | 712 num_bits += (kDigitBitSize * (b_length - 1)); |
| 710 if (num_bits > 64) return false; | 713 if (num_bits > 64) return false; |
| 711 return true; | 714 return true; |
| 712 } | 715 } |
| 713 | 716 |
| 714 | 717 |
| 715 bool BigintOperations::FitsIntoUint64(const Bigint& bigint) { | 718 bool BigintOperations::FitsIntoUint64(const Bigint& bigint) { |
| 716 if (bigint.IsNegative()) return false; | 719 if (bigint.IsNegative()) return false; |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1808 intptr_t BigintOperations::CountBits(Chunk digit) { | 1811 intptr_t BigintOperations::CountBits(Chunk digit) { |
| 1809 intptr_t result = 0; | 1812 intptr_t result = 0; |
| 1810 while (digit != 0) { | 1813 while (digit != 0) { |
| 1811 digit >>= 1; | 1814 digit >>= 1; |
| 1812 result++; | 1815 result++; |
| 1813 } | 1816 } |
| 1814 return result; | 1817 return result; |
| 1815 } | 1818 } |
| 1816 | 1819 |
| 1817 } // namespace dart | 1820 } // namespace dart |
| OLD | NEW |