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

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

Issue 9600078: Make pow call unambiguous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | « no previous file | no next file » | 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/utils.h" 5 #include "platform/utils.h"
6 6
7 #include "vm/double_internals.h" 7 #include "vm/double_internals.h"
8 #include "vm/exceptions.h" 8 #include "vm/exceptions.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/zone.h" 10 #include "vm/zone.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 // We will fill the result in the inverse order and then exchange at the end. 372 // We will fill the result in the inverse order and then exchange at the end.
373 char* result = 373 char* result =
374 reinterpret_cast<char*>(allocator(static_cast<intptr_t>(required_size))); 374 reinterpret_cast<char*>(allocator(static_cast<intptr_t>(required_size)));
375 ASSERT(result != NULL); 375 ASSERT(result != NULL);
376 int result_pos = 0; 376 int result_pos = 0;
377 377
378 // We divide the input into pieces of ~27 bits which can be efficiently 378 // We divide the input into pieces of ~27 bits which can be efficiently
379 // handled. 379 // handled.
380 const intptr_t kDivisorValue = 100000000; 380 const intptr_t kDivisorValue = 100000000;
381 const int kPowerOfTen = 8; 381 const int kPowerOfTen = 8;
382 ASSERT(pow(10, kPowerOfTen) == kDivisorValue); 382 ASSERT(pow(10.0, kPowerOfTen) == kDivisorValue);
383 ASSERT(static_cast<Chunk>(kDivisorValue) < kDigitMaxValue); 383 ASSERT(static_cast<Chunk>(kDivisorValue) < kDigitMaxValue);
384 ASSERT(Smi::IsValid(kDivisorValue)); 384 ASSERT(Smi::IsValid(kDivisorValue));
385 const Bigint& divisor = Bigint::Handle(NewFromInt64(kDivisorValue)); 385 const Bigint& divisor = Bigint::Handle(NewFromInt64(kDivisorValue));
386 386
387 // Rest contains the remaining bigint that needs to be printed. 387 // Rest contains the remaining bigint that needs to be printed.
388 Bigint& rest = Bigint::Handle(bigint.raw()); 388 Bigint& rest = Bigint::Handle(bigint.raw());
389 Bigint& quotient = Bigint::Handle(); 389 Bigint& quotient = Bigint::Handle();
390 Bigint& remainder = Bigint::Handle(); 390 Bigint& remainder = Bigint::Handle();
391 while (!rest.IsZero()) { 391 while (!rest.IsZero()) {
392 DivideRemainder(rest, divisor, &quotient, &remainder); 392 DivideRemainder(rest, divisor, &quotient, &remainder);
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 int BigintOperations::CountBits(Chunk digit) { 1502 int BigintOperations::CountBits(Chunk digit) {
1503 int result = 0; 1503 int result = 0;
1504 while (digit != 0) { 1504 while (digit != 0) {
1505 digit >>= 1; 1505 digit >>= 1;
1506 result++; 1506 result++;
1507 } 1507 }
1508 return result; 1508 return result;
1509 } 1509 }
1510 1510
1511 } // namespace dart 1511 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698