Suppose we have this code:

long a = 0x1_0000_0000L + 0xCAFE_BABE; System.out.println(a == 0x1_CAFE_BABEL); 

Why will false be displayed? In theory, the number 0xCAFE_BABE should be automatically extended to the long type, and after that addition should occur.

    1 answer 1

    and it happens. Just 0xCAFE_BABE is negative (!), So it is reduced to negative long - y.

    Those. (long)(0xCAFE_BABE) (exactly in such a record) is FFFF_FFFF_CAFE_BABE which is a little different from what you expected. Therefore, numbers greater than 7FFF_FFFF in such situations need to be written only with the suffix L.