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

[BUG] Incorrect Binary Addition Logic in add_strings in divide_and_conquer/karatsuba_algorithm_for_fast_multiplication.cpp #2848

Open
shrivalidutt opened this issue Oct 16, 2024 · 0 comments · May be fixed by #2862
Labels

Comments

@shrivalidutt
Copy link

Description

The current implementation of add_strings contains an issue with how bits are summed and inserted into the result string. The bitwise XOR and carry logic is incorrect. It incorrectly treats the sum and carry operation as a character instead of using integer arithmetic.

Expected behavior

The function add_strings is supposed to correctly sum two binary strings, handling the addition of bits along with managing carry.

Actual behavior

Instead of performing correct integer arithmetic for binary addition, the function uses bitwise XOR and character casting, leading to incorrect results.

Steps to reproduce

No response

Context

The incorrect use of XOR and char casting caused the function to fail at handling binary addition properly. This bug results in faulty summation, especially when there is a carry involved between bit positions.

Additional information

The bug causes the program to produce incorrect results for binary multiplication.

@shrivalidutt shrivalidutt changed the title [BUG] Incorrect Binary Addition Logic in add_strings [BUG] Incorrect Binary Addition Logic in add_strings in divide_and_conquer/karatsuba_algorithm_for_fast_multiplication.cpp Oct 16, 2024
@chitvs chitvs linked a pull request Oct 19, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant