zlacker

[parent] [thread] 4 comments
1. yread+(OP)[view] [source] 2020-04-03 09:11:42

   > parseInt("0123Test")
   123
   > 0123
   83
parseInt is actually the adult in the room
replies(2): >>TeMPOr+4 >>hurflm+Hx
2. TeMPOr+4[view] [source] 2020-04-03 09:12:57
>>yread+(OP)
In a way. The convention is that 0123 is "123" in octal.
replies(1): >>yread+s4
◧◩
3. yread+s4[view] [source] [discussion] 2020-04-03 10:10:01
>>TeMPOr+4
Yes, I know that's why I even tried it in console as I was a bit surprised that parseInt doesn't do octal.

Why does js even support octal? I never found octal particularly useful. Speak hexadecimal or die

replies(1): >>sweene+37
◧◩◪
4. sweene+37[view] [source] [discussion] 2020-04-03 10:45:34
>>yread+s4
Because C does.
5. hurflm+Hx[view] [source] 2020-04-03 14:37:22
>>yread+(OP)

    > parseInt('0123Test', 8)
    83
you could do it like this, otherwise it uses the default value for the base parameter.
[go to top]