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.
Copyright © 2021 Jogjafile Inc.
Regardless of the language you are using, here is an attempt at a general explanation:
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 thatcorrectly yields
4if you're in binary andcorrectly yields
100in decimal.Recommended Reading: Number Systems and Bases