It seems that it only compares the size relationship of the first few significant digits? If the number is too long, some strange phenomena will appear.
double a = 1.9;
double b = 1.8;
System.out.println(a > b); // return true
double c = 9007199254740990.9;
double d = 9007199254740990.8;
System.out.println(c > d); // return false
When program source code is compiled or otherwise translated or analyzed, the numerals of floating-point constants in the source code are converted to a floating-point format.
When a numeral is converted to IEEE-754 “double precision” format (also called binary64), the result should be the nearest value representable in that format in the direction determined by the rounding rule in use. The default rounding rule is round-to-nearest ties-to-even.
When 1.9 is converted in this way, the result is 1.899999999999999911182158029987476766109466552734375, because that is the closest representable value to 1.9. The second closest number is 1.9000000000000001332267629550187848508358001708984375, and that is a little farther from 1.9 than 1.899999999999999911182158029987476766109466552734375 is.
When 1.8 is converted, the result is 1.8000000000000000444089209850062616169452667236328125. The former is greater than the latter, so a > b
evaluates as true.
When 9007199254740990.9 is converted, the result is 9007199254740991. When 9007199254740990.8, the result is 9007199254740991. These are equal, so c > d
evaluates as false.