Hacker News new | ask | show | jobs
by ajuc 1453 days ago
Yes, also there are deep magic gamedev tricks exploiting that (see quake sqrt :) ). There should be a way to do them. Something like bit_compare(x, y). I'd just prefer if rarely useful operations shouldn't use the most commonly used API. Too easy to make a mistake.

BTW I'd also love to have a built in float type that fails when you assign 0 to it.

Anyway, I guess in Java operator == is a lost cause anyway. My favorite example:

    // true
    System.out.println(BigDecimal.valueOf(10) == BigDecimal.valueOf(10));
    // false
    System.out.println(BigDecimal.valueOf(11) == BigDecimal.valueOf(11));
    // true
    System.out.println(BigDecimal.valueOf(11).equals(BigDecimal.valueOf(11)));