Skip to content

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

@leren1

Description

@leren1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions