"08".toNumber() = 0

Converting the string "08" or "09" with toNumber function, both produces the integer value 0 on a Forerunner 920XT with lastest firmware.

In the simulator the result is as expected ("08".toNumber() = 8 and "09".toNumber() = 9).

Not sure if this is a Monkey C language feature :-)

Code snippet and output:

for (var i = 0; i < 10; i++) {
var strI = i.toString();
var intI = strI.toNumber();
var dblI = intI.toDouble();

Sys.println("i: " + i + ", strI: " + strI + ", intI: " + intI + ", dblI: " + dblI);

strI = "0" + i.toString();
intI = strI.toNumber();
dblI = intI.toDouble();

Sys.println("i: " + i + ", strI: " + strI + ", intI: " + intI + ", dblI: " + dblI);
}

i: 0, strI: 0, intI: 0, dblI: 0.000000
i: 0, strI: 00, intI: 0, dblI: 0.000000
i: 1, strI: 1, intI: 1, dblI: 1.000000
i: 1, strI: 01, intI: 1, dblI: 1.000000
i: 2, strI: 2, intI: 2, dblI: 2.000000
i: 2, strI: 02, intI: 2, dblI: 2.000000
i: 3, strI: 3, intI: 3, dblI: 3.000000
i: 3, strI: 03, intI: 3, dblI: 3.000000
i: 4, strI: 4, intI: 4, dblI: 4.000000
i: 4, strI: 04, intI: 4, dblI: 4.000000
i: 5, strI: 5, intI: 5, dblI: 5.000000
i: 5, strI: 05, intI: 5, dblI: 5.000000
i: 6, strI: 6, intI: 6, dblI: 6.000000
i: 6, strI: 06, intI: 6, dblI: 6.000000
i: 7, strI: 7, intI: 7, dblI: 7.000000
i: 7, strI: 07, intI: 7, dblI: 7.000000
i: 8, strI: 8, intI: 8, dblI: 8.000000
i: 8, strI: 08, intI: 0, dblI: 0.000000
i: 9, strI: 9, intI: 9, dblI: 9.000000
i: 9, strI: 09, intI: 0, dblI: 0.000000
  • Hey everyone,

    I was able to test this again with a new beta firmware build and this has been fixed. The next public release should fix this issue for you. To confirm, I tried with the beta build, then rolled back to the latest public build. 08 and 09 were being cast to 0 in 8.40, but cast to 8 and 9 respectively on the latest beta build. Thanks for checking this out!

    -Coleman