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

Fix binary addition logic in add_strings function #2862

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chitvs
Copy link

@chitvs chitvs commented Oct 19, 2024

Description of Change

This pull request addresses a bug in the add_strings function located in divide_and_conquer/karatsuba_algorithm_for_fast_multiplication.cpp. The original implementation incorrectly used bitwise XOR and character casting for binary addition, leading to incorrect results during binary multiplication. The updated code uses proper integer arithmetic to handle binary addition correctly, ensuring accurate summation of binary strings.

Fixes #2848 (Incorrect Binary Addition Logic in add_strings).

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: This fix corrects the binary addition logic, ensuring accurate results for binary multiplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant