Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions library/core/src/num/bignum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ macro_rules! impl_full_ops {
fn full_mul_add(self, other: $ty, other2: $ty, carry: $ty) -> ($ty, $ty) {
// This cannot overflow;
// the output is between `0` and `2^nbits * (2^nbits - 1)`.
let v = (self as $bigty) * (other as $bigty) + (other2 as $bigty) +
(carry as $bigty);
((v >> <$ty>::BITS) as $ty, v as $ty)
let (lo, hi) = self.carrying_mul_add(other, other2, carry);
(hi, lo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting that this method had picked the opposite order. I guess we were all taught math in big-endian, even if it's kinda worse 🙃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it was not obvious at first, so it took some time to understand why tests are not passing

}

fn full_div_rem(self, other: $ty, borrow: $ty) -> ($ty, $ty) {
Expand Down
Loading