Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ternary big integers common parts #102

Merged

Conversation

thibault-martinez
Copy link
Member

@thibault-martinez thibault-martinez commented Jul 13, 2020

Description of change

Adds common parts of ternary big integers.

Links to any relevant issues

Part of #77

Change checklist

Tick the boxes that are relevant to your changes, and delete any items that are not.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes
  • I have updated the CHANGELOG.md, if my changes are significant enough

bee-ternary/src/bigint/binary_representation.rs Outdated Show resolved Hide resolved
bee-ternary/src/bigint/binary_representation.rs Outdated Show resolved Hide resolved
bee-ternary/src/bigint/binary_representation.rs Outdated Show resolved Hide resolved
bee-ternary/src/bigint/binary_representation.rs Outdated Show resolved Hide resolved
bee-ternary/src/bigint/overflowing_add.rs Outdated Show resolved Hide resolved
bee-ternary/src/bigint/split_integer.rs Show resolved Hide resolved
bee-ternary/src/bigint/endianness.rs Outdated Show resolved Hide resolved
bee-ternary/src/bigint/endianness.rs Outdated Show resolved Hide resolved
bee-ternary/src/bigint/endianness.rs Outdated Show resolved Hide resolved
@Alex6323 Alex6323 self-requested a review July 14, 2020 08:33

impl OverflowingAdd for u32 {
fn overflowing_add_with_carry(self, other: Self, carry: Self) -> (Self, bool) {
let (sum, first_overflow) = self.overflowing_add(other);
Copy link
Contributor

@zesterer zesterer Jul 14, 2020

Choose a reason for hiding this comment

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

I'm not entirely sure what the purpose of this code is, could you explain? I see that there's an add-plus-carry but I'm not sure what context this all might be useful in.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not the author of the code but I'll try to explain.
When dealing with big integers you have a lot of carry propagation to handle. This piece of code is just an extension of the overflowing add with a carry. It could technically be done without this function but this is just to DRY things I assume.

@thibault-martinez thibault-martinez merged commit d852d4f into iotaledger:master Jul 14, 2020
@thibault-martinez thibault-martinez deleted the ternary-bigint-common branch July 14, 2020 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-feature Category - Feature e-medium Experience - Medium p-high Priority - High wg-ternary Working Group - Ternary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants