We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8bf7492 commit fe61eb2Copy full SHA for fe61eb2
src/main/java/com/thealgorithms/maths/FFT.java
@@ -142,8 +142,10 @@ public double abs() {
142
*/
143
public Complex divide(Complex z) {
144
Complex temp = new Complex();
145
- temp.real = (this.real * z.real + this.img * z.img) / (z.abs() * z.abs());
146
- temp.img = (this.img * z.real - this.real * z.img) / (z.abs() * z.abs());
+ double d = z.abs() * z.abs();
+ d = (double)Math.round(d * 1000000000d) / 1000000000d;
147
+ temp.real = (this.real * z.real + this.img * z.img) / (d);
148
+ temp.img = (this.img * z.real - this.real * z.img) / (d);
149
return temp;
150
}
151
0 commit comments