ParseInt 3.5.7

It seems that the parseInt second argument [, base] that was optional (and maybe default 10) became mandatory for decimal conversion

for exemple

var vtest=parsint('07') //vtest = 7 is ok
var vtest=parseInt('08') // vtest = NaN is Not ok  
var vtest=parseInt('08',10) //vtest = 8 is ok
var vtest=parseInt('16') //vtest = 16 is ok
var vtest=parseInt('016') //vtest = 14 is Not ok servoy seems to think that it's an octal value, it why my second line was NaN

Must I conclude that if my string starts with zero servoy think that it’s an octal value?

It looks like it indeed ( according to my log :) )

If it is, please file this in our support system.

Paul

This behavior is in variance with the current JavaScript spec, which says base 10 should be assumed as the radix unless the string begins with ‘0x’ – however, it is the standard behavior of almost all javascript interpreters.

Firefox (including v3), IE (including v7) will also assume an octal radix if you pass a string starting with “0” to parseInt. So, this isn’t a Servoy issue, it’s a general javascript issue…and is not new, Servoy’s always done this as far as I know.

It’s best just to be explicit and pass the radix when calling parseInt.

greg.

I agree I test on older version of Version and the behaviour was here too.

Maybe i had never be in this case before

Thanks for your answers (i’ll now explicitly choose and pass my radix)