The following simple floating point arithmetic operation is not working as expected.
double den = (1+j);
System.out.println(den);
den = 1/den;
System.out.println(den);
double newden = 1/(1+j);
System.out.println(newden);
The above code gives the following output.
7.0
0.14285714285714285
0.0
As shown above, the first two operations work as expected but the last doesn't. I suppose that it has something to do with the variable type but still haven't figured out the problem.
Can you please explain the behaviour of arithmetic operations in Java?