Can someone please explain what radix is (on the most fundamental level), in reference to parseInt()?
I'm also not understanding how the string argument changes with different bases/radix.
Can someone please explain what radix is (on the most fundamental level), in reference to parseInt()?
I'm also not understanding how the string argument changes with different bases/radix.
Regardless of the language you are using, here is an attempt at a general explanation:
The radix is the base of a numeral system.
Decimal system: radix is 10, therefore 10010 means 100.
Binary system: radix is 2, therefore 1002 means 4.
This is why parseInt(number, radix)
needs to know the radix you are working with, so that
parseInt(100, 2)
correctly yields 4
if you're in binary and
parseInt(100, 10)
correctly yields 100
in decimal.
Recommended Reading: Number Systems and Bases