Question maybe very simple. Checked the equality of two Primitive types, then got some mistakes. One of the double, second one long.
public class TesterPrimitive {
public static void main(String[] args) {
System.out.println("Equality - " + (5.0 == 5)); // Return true
System.out.println("Equality - " + (5.000000000000001D == 5L)); // Return false
System.out.println("Equality - " + (5.0000000000000001D == 5L)); // Return true
}}
Why for third equality, for double and long, I got true? Is it means, long 0 numbers after (.), change any value to absolute 0? Or is it changing bits and then we can get 5.0 for double?