| 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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 RawBigint* BigintOperations::Divide(const Bigint& a, const Bigint& b) { | 769 RawBigint* BigintOperations::Divide(const Bigint& a, const Bigint& b) { |
| 770 Bigint& quotient = Bigint::Handle(); | 770 Bigint& quotient = Bigint::Handle(); |
| 771 Bigint& remainder = Bigint::Handle(); | 771 Bigint& remainder = Bigint::Handle(); |
| 772 DivideRemainder(a, b, "ient, &remainder); | 772 DivideRemainder(a, b, "ient, &remainder); |
| 773 return quotient.raw(); | 773 return quotient.raw(); |
| 774 } | 774 } |
| 775 | 775 |
| 776 | 776 |
| 777 RawBigint* BigintOperations::Modulo(const Bigint& a, const Bigint& b) { | 777 RawBigint* BigintOperations::Modulo(const Bigint& a, const Bigint& b) { |
| 778 Bigint& quotient = Bigint::Handle(); | 778 Bigint& quotient = Bigint::Handle(); |
| 779 Bigint& modulo = Bigint::Handle(); | 779 Bigint& remainder = Bigint::Handle(); |
| 780 DivideRemainder(a, b, "ient, &modulo); | 780 DivideRemainder(a, b, "ient, &remainder); |
| 781 return modulo.raw(); | 781 // Emulating code in Integer::ArithmeticOp (Euclidian modulo). |
| 782 if (remainder.IsNegative()) { |
| 783 if (b.IsNegative()) { |
| 784 return BigintOperations::Subtract(remainder, b); |
| 785 } else { |
| 786 return BigintOperations::Add(remainder, b); |
| 787 } |
| 788 } |
| 789 return remainder.raw(); |
| 782 } | 790 } |
| 783 | 791 |
| 784 | 792 |
| 785 RawBigint* BigintOperations::Remainder(const Bigint& a, const Bigint& b) { | 793 RawBigint* BigintOperations::Remainder(const Bigint& a, const Bigint& b) { |
| 786 Bigint& quotient = Bigint::Handle(); | 794 Bigint& quotient = Bigint::Handle(); |
| 787 Bigint& remainder = Bigint::Handle(); | 795 Bigint& remainder = Bigint::Handle(); |
| 788 DivideRemainder(a, b, "ient, &remainder); | 796 DivideRemainder(a, b, "ient, &remainder); |
| 789 return remainder.raw(); | 797 return remainder.raw(); |
| 790 } | 798 } |
| 791 | 799 |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1648 int BigintOperations::CountBits(Chunk digit) { | 1656 int BigintOperations::CountBits(Chunk digit) { |
| 1649 int result = 0; | 1657 int result = 0; |
| 1650 while (digit != 0) { | 1658 while (digit != 0) { |
| 1651 digit >>= 1; | 1659 digit >>= 1; |
| 1652 result++; | 1660 result++; |
| 1653 } | 1661 } |
| 1654 return result; | 1662 return result; |
| 1655 } | 1663 } |
| 1656 | 1664 |
| 1657 } // namespace dart | 1665 } // namespace dart |
| OLD | NEW |