Skip to content

FFT.Java - Bug in divide(Complex z) #2961

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

Closed
leren1 opened this issue Feb 24, 2022 · 1 comment
Closed

FFT.Java - Bug in divide(Complex z) #2961

leren1 opened this issue Feb 24, 2022 · 1 comment

Comments

@leren1
Copy link
Contributor

leren1 commented Feb 24, 2022

Describe the bug
A clear and concise description of what the bug is.

There is a rounding error in the function. It arises when the function divides with (z.abs() * z.abs())

To Reproduce

Steps to reproduce the behavior:

Run this code to test it, either in main or a Junit test.:
FFT.Complex complex1 = new FFT.Complex(2.0,2.0);
FFT.Complex complex2 = new FFT.Complex(1.0,2.0);
double divReal = complex1.divide(complex2).getReal();
double divImg = complex1.divide(complex2).getImaginary();
assertEquals(1.2,divReal);
assertEquals(-0.4,divImg);

Expected behavior

The value from divReal should be 1.2 exactly, instead, it returns 1.199999...

Solution
A solution might be to round the value at 10^-9.

leren1 added a commit to DD2480group1/Java that referenced this issue Feb 24, 2022
@leren1
Copy link
Contributor Author

leren1 commented Feb 24, 2022

Added the code, waiting for review

@siriak siriak closed this as completed in fe61eb2 Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant