Acknowledged

Bug in Simulator 7.2.1 with Float vs Long comparisons

In the following:

    var l = 1L;
    var f = 1.0f;
    System.println(f==l); // false in 7.2.1, true in 7.2.0 and earlier
    System.println(l==f); // false in 7.2.1, true in 7.2.0 and earlier
    System.println(1.0f==1L); // false in 7.2.1 with optimization off, true with optimization on

Essentially, when the 7.2.1 simulator evaluates 1.0f==1L it returns false. All previous simulators return true.

Note that the optimizer also thinks the result is true.

I've not tried on a device yet, but from past experiments I'm pretty sure that all the watches I've used report true.

If this is something that's going to change, or that devices are inconsistent about, the type checker should issue a warning for long vs float comparisons, and the optimizer shouldn't optimize constant comparisons (especially not to the wrong value!). But my guess is that this is just a bug in the simulator.

Parents
  • This might be related to the fact, that 7.2.1 has the following line in the release notes under general (not simulator) changes section:

    • Fix a behavioral inconsistency for older devices when equality comparing objects of various types.
Comment
  • This might be related to the fact, that 7.2.1 has the following line in the release notes under general (not simulator) changes section:

    • Fix a behavioral inconsistency for older devices when equality comparing objects of various types.
Children
No Data