Use the parseInt Function with a Radix 2019

in 101 in decimals there is a 1 in the threes column and there is no forth number.

I get how you got forth column. 2^2 is 4.

In the base-ten system, 101 says “one in the hundreds column (10^2), zero in the tens column (10^1), and one in the ones column (10^0): 100 + 0 + 1”.

so the answer is 56.

for 10011 in binary, the answer is 0+2+6+16+32= 56

VERY close. the left-most column is 2^4, or 16. Start counting columns from the right, remembering that the rightmost column is “to the power of ZERO,” then to the power of one – what’s the power of the FIFTH column from the right (or, in this case, the first column from the left)?

the answer is 52. I was using my phone calculator and must have put 6 instead of 4

is the last column to the right 64?

1 in base-2 = 1; 10 in base-2 (or binary) is 2; 100 in base-2 is 4; 1000 in base-2 is 8; 10000 in base-2 (following that same pattern of doubling) is…?

Im confused again. I thought you said its 2^(placement of the number by column. For example 10011 is 2^0=0, 2^1=1, 2^2=4, 2^3=8, 2^4=16,2^5=32,
0+1+4+8+16+32=61

But that 32 is in the sixth column of your five-digit binary number…

the answer is 29 …

thanks for being patient with me as I figured this out!

On the wikipedia page, https://en.m.wikipedia.org/wiki/Binary_number, look for “Counting in Binary”. It’s a great explanation.

If you are interested in how each numeral system works, it’s probably easier if you try to look online for resources that aim to explain those in a more broad and easy way.

Then if you want, you can dig deeper into the math reasoning behind that.

For the time being I’d say that the most important take-away is to understand that when you ask a computer to convert a string into a number, you have to be explicit also on how that number should be converted because there’s more that just one way to treat that number.

Then in my experience the most frequent system you’d find while working as a dev are:

note: used by but not limited to*

  • binary
    used* by the computer

  • octal
    used* inUnix-like system for permissions

  • decimal
    used by me* as a human being (or am I a bot? :thinking:)

  • hexadecimal
    used* by the design team when they want to tell me that the red button is #FF0000
    (do you remember it from the CSS section?), well that’s a hexadecimal number :slight_smile:

3 Likes

My solution is:

function convertToInteger(str, radix) {
return parseInt(str, 2);
}

console.log(convertToInteger(“11011”));