Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(858)

Side by Side Diff: runtime/vm/bigint_operations.cc

Issue 136453012: Fix http://dartbug.com/16111 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/math.cc ('k') | sdk/lib/math/random.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « runtime/lib/math.cc ('k') | sdk/lib/math/random.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698