+ 1
Hi im new learner and i noticed in Javascript for the tests there's always input given but why is it always "10"?
parseInt(readLine(), 10); What is the 10 meaning?
3 ответов
+ 4
it's base of number system to be converted from input of string type.
Base 10 : decimal numbers
Base 2 : binary
Base 8 : octal, etc..
+ 4
Pravesh Maharaj the second parameter, radix, tells parseInt() what number base to use for interpreting the value. Most of the time you expect input in base 10 (decimal) so 10 is the radix. Radix 10 means there are 10 possible digits, 0 - 9.
If the input number should be in binary, then radix is 2 because there are two possible digits, 0 - 1. For octal the radix is 8 (0 - 7), and for hexadecimal, radix is 16 (0 - F).
+ 1
Thank you both!