Skip to content

fix: prevent carry from persisting between digit additions in bigint::addition #6

Description

@JohannaGcd

Hi! :) I noticed a small (potential) bug. In bigint, addition(), carry should be reset to 0 whenever the current sum does not produce a carry (otherwise it would keep its old value from the previous digit).

As an example:
19 + 11

  • adding the ones: 9 + 1 = 10 so carry = 1
  • adding the tens: 1 + 1 + 1 = 3, no new carry
    here, carry stays 1, so you would append 1 at the end.

Fix: add a carry = 0 in the else block (line 101)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions