Here is the interview question prompt, presented for reference.
Today, we're going to do some math! There is only one prerequisite for answering this question, and it is knowing the definitions of
According to How to Convert Decimal to Binary and Binary to Decimal,
binary is a numeric system that only uses two digits — 0 and 1. Computers operate in binary, meaning they store data and perform calculations using only zeros and ones.
Decimal, on the other hand, is "a number system that uses a notation in which each number is expressed in base 10 by using one of the first nine integers or 0 in each place and letting each place value be a power of 10."
Can you write a function that returns the binary string of a given decimal number? For example, if the input was
decimalToBinary(3); // 11
11 because it is the binary representation of
3 (1 x 2 + 1 x 1).
For more background on this, read this great article on converting: How to Convert Decimal to Binary and Binary to Decimal.
You can see the full challenge with visuals at this link.
Challenges • Asked almost 2 years ago by Anonymous
This is the main discussion thread generated for Decimal To Binary.
Hi, I appreciate that you've backlinked to my article, but since you've used a fragment of it, use the title in the text of the backlink. I.e. "How to Convert Decimal to Binary and Binary to Decimal".
How to Convert Decimal to Binary and Binary to Decimal
by Eugene Brennan
Thanks for your comment. We updated the article and added your citation properly.