| 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/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 Loading... |
| 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, "ient, &remainder); | 392 DivideRemainder(rest, divisor, "ient, &remainder); |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |