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 in polynomial multiplication #20

Closed
potat-dev opened this issue Feb 16, 2022 · 1 comment
Closed

Bug in polynomial multiplication #20

potat-dev opened this issue Feb 16, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@potat-dev
Copy link
Owner

When I try to multiply two polynomials like this:
https://github.com/CyberPotat42/SUAI-Labs/blob/619dbbbf28ac68fabacb6bf25052866939f0047d/Semester_2/Lab_9/main.cpp#L84-L95

This works great!

x - 1
x - 2
x^2 - 3x + 2

But when i try to multiply them in a loop:
https://github.com/CyberPotat42/SUAI-Labs/blob/619dbbbf28ac68fabacb6bf25052866939f0047d/Semester_2/Lab_9/main.cpp#L105-L118

Then for some reason the wrong answer is given:

input n = 2
input 2 numbers: 1 2

x - 1
x - 2
x^2 - 4x + 4

Perhaps this is due to incorrect handling of pointers or a memory leak
I think it's time for me to sleep 💤

@potat-dev potat-dev self-assigned this Feb 16, 2022
@potat-dev potat-dev added the bug Something isn't working label Feb 16, 2022
@potat-dev
Copy link
Owner Author

I was right, it was the wrong pointer handling - I used the same array in two polynomials at the same time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant