parseInt seems to have massive problems with 8 and 9 when you add leading ZEROS to it.
exampel script:
for (i=0;i<10;i++){
strNumber=i.toString();
System.log(strNumber);
System.log(parseInt("0"+strNumber));
System.log(parseInt("00"+strNumber));
System.log(parseInt("000"+strNumber));
System.log(parseInt("0000"+strNumber));
}
output:
[2017-06-01 10:01:10.222] [I] 0
[2017-06-01 10:01:10.223] [I] 0
[2017-06-01 10:01:10.224] [I] 0
[2017-06-01 10:01:10.225] [I] 0
[2017-06-01 10:01:10.226] [I] 0
[2017-06-01 10:01:10.227] [I] 1
[2017-06-01 10:01:10.228] [I] 1
[2017-06-01 10:01:10.229] [I] 1
[2017-06-01 10:01:10.230] [I] 1
[2017-06-01 10:01:10.231] [I] 1
...
[2017-06-01 10:01:10.257] [I] 7
[2017-06-01 10:01:10.258] [I] 7
[2017-06-01 10:01:10.259] [I] 7
[2017-06-01 10:01:10.260] [I] 7
[2017-06-01 10:01:10.261] [I] 7
[2017-06-01 10:01:10.262] [I] 8
[2017-06-01 10:01:10.263] [I] NaN
[2017-06-01 10:01:10.264] [I] 0
[2017-06-01 10:01:10.265] [I] 0
[2017-06-01 10:01:10.266] [I] 0
[2017-06-01 10:01:10.267] [I] 9
[2017-06-01 10:01:10.268] [I] NaN
[2017-06-01 10:01:10.269] [I] 0
[2017-06-01 10:01:10.270] [I] 0
[2017-06-01 10:01:10.271] [I] 0
What one has to do is:
parseInt(nun,10);
The ,10 is an old depricated feature of parseInt that lets you choose your BASE...and we want the 10 base not ocatal (8 = default when leading 0)....thats why it fails at 8 and 9.
wonderFOOL
for (i=0;i<10;i++){
strNumber=i.toString();
System.log(strNumber);
System.log(parseInt("0"+strNumber,10));
System.log(parseInt("00"+strNumber,10));
System.log(parseInt("000"+strNumber,10));
System.log(parseInt("0000"+strNumber,10));
}