I am aware of the floating point errors as I had gained some knowledge with my question asked here in SE Floating Point Errors.
What I am finding it difficult to understand is, the output of the following program.
double d1 = 0 + 1.123 + 2.456;
double d2 = 3.579;
float f1 = 0f + 1.123f + 2.456f;
float f2 = 3.579f;
long l1 = (long)(0 + 1.123 + 2.456);
long l2 = (long)3.579;
System.out.println(d1==d2); // Output = false;
System.out.println(f1==f2); // Output = true;
System.out.println(l1==l2); // Output = true;
Why is the output "false" for double and not for float, even when float is single precision 32 bit and double is double precision 64 bit. Oracle docs
Any help with this would be highly appreciated.