3
$\begingroup$

I've just started learning binary so mind me if I'm bad at this. I think that the binary for 1 ought to be just "1" but, when I key it in to an app I downloaded, the answer has extra 0s and 11s in it. Why?

enter image description here

$\endgroup$
0

2 Answers 2

4
$\begingroup$

The app you have converts strings in the ASCII character set to their binary representation. This representation assigns eight bits for each character in the string. For example, the word "cat" is composed of characters number 99, 97 and 116, which is 01100011 01100001 01110100.

What your app is doing is converting the string "1" into its binary ASCII representation. "1" is character number 49 in ASCII, which is 00110001, and it's pure coincidence that this ends in a 1.

You're completely correct that, as a number, 1 in decimal is 1 in binary.

$\endgroup$
1
  • $\begingroup$ Well, I say "it's pure coincidence"; the decimal digit $d$ is coded in ASCII as the decimal number $48+d$, so the last four bits of the ASCII representation of any decimal digit $d$ is actually $d$ represented in bianry. That was probably by design, rather than coincidence. $\endgroup$ Oct 27, 2018 at 22:07
3
$\begingroup$

What you see is the ASCII code for the digit 1, in binary.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.