I don’t understand what the value of a parseInt() if we given a string ‘11’ and a radix of 2. This is the example given in the curriculum challenge by the way. Here it is :
Const parsed = parseInt('11',2);
The value of parsed is 3. Why 3 and not another number? How did it get the value 3 and what does it represent?
Thank you.
I feel like @snowmonkey should get into this.
Yeah, please don’t @ random mods, people on the forum will answer you if they’re able.
“11” is the number two in binary, anyway, somebody just asked same thing, this answer I wrote might be helpful (might not, it’s more analogy than anything else but hey ho):
In only the last link i could understand why did we get the number 3 as a result. Everything else i found already on internet.
I guess google present diffrent results depends on diffrent countries.
You probably get better results as google knows you speak english in your country, but in here google thinks our second lang is french, so when i search in english, i dont get the best.
Thanx any way jermino.
Sorry to @ random people.
The first thing to understand are the place values.
As you can see we have a 1’s place, 2’s place, 4’s place, 8’s place, etc.
It goes all the way up to 128’s place.
Here are where the place values come from
20 equals 1
21 equals 2
22 equals 4
etc…
All of that is explained in the resources I linked.
Once you understand the place values then it is just about placing the 1’s and 0’s in the correct places.
If you want to find what 3 is in binary then you place a 1 in the 1’s place and a 1 in the 2’s place.
1+2 = 3
You can follow that same process for any number.
For example if you wanted to know what the number 13 is in binary.