Monkey C: 0.0 treated as true value

Environment: CIQ 3.0.5
(Tested in both CIQ1 and CIQ2+ watches in simulator. Known to happen on real CIQ2+ watch)

Unlike C, Javascript and probably every other programming language in the world, 0.0 is treated as a true value.

Also, 0.0 is treated as true, but "0 == 0.0" is true (as it should be), which is logically incoherent. If x == y, one can't be true while the other is false.

I can't even post the code to the forums (as per usual), so it's all on pastebin:
https://pastebin.com/KKZGUu3m

Output:
0 == 0.0: PASSED....
0.0 is truthy: FAILED....
0 is falsey: PASSED....



All I can say is that Monkey C and Connect IQ have really laudable design goals and great potential, but I think stuff like this is a huge disincentive to devs. There's no substitute for testing, but we shouldn't have to test obvious language constructs to see if they work the same way as expected.

Furthermore, we still can't post code in the forums.... A huge disincentive to participate in the community. The amount of effort I had to expend just to post this bug report is ridiculous.

I get that Garmin has higher priorities, like promoting the Spider-Man watchface (hey, I liked Spider-Man: Homecoming) and not updating the Uber/Lyft apps.
  • Not to beat a dead horse, but in a duck-typed language, I would expect as many implicit conversions to be allowed as possible.

    Agreed.

    I've looked at this a little bit, and found some other weirdness. This one is particularly disturbing.
    var x = !2; // does not compile

    var y = 2;
    y = !y;
    System.println(y); // prints -3 which is ~2


  • Agreed.

    I've looked at this a little bit, and found some other weirdness. This one is particularly disturbing.
    var x = !2; // does not compile

    var y = 2;
    y = !y;
    System.println(y); // prints -3 which is ~2




    I think this is similar to another bug report from over a year ago where x && y is treated as bitwise AND instead of logical AND. Or was that OR?

    For some reason, the bitwise and logical operators seem to be conflated in a few places....
  • Former Member
    Former Member over 6 years ago
    MonkeyC only has one of each of the 'not', 'and', and 'or' opcodes. These are automatically treated as logical if any arguments are boolean, and otherwise treated as a bit operation.

    (I have facts only here, I will be unable to answer your obvious follow up of "but why?")
  • Brian.ConnectIQ thanks! Well, ever since the initial bug report, I had a sneaking suspicion it has something to do with limited resources, especially on older watches....

    Either way, I know it's not going to change.