How do you code in binary from ASCII?

Status
Not open for further replies.

Jayce

Fully Optimized
Messages
3,056
Location
/home/jason
Long story short... we were shown like 2 examples of how to code in binary and that was that. I thought I was doing it right... we were supposed to code our full name and turn it in to the instructor. But when I looked up a binary/ascii chart online and compared it to what I got, mine were completely wrong. I don't know what I did wrong.

Let me try my best to explain how I did what I did.

Let's say I'm using the ASCII number 74, which I believe is capital J. First I'd set up my chart like this...


1024 512 256 128 64 32 16 8 4 2 1

Then using that chart, I'd basically see what adds up to 74, going from left to right. For example, for 74 I'd do the following, putting a 0 under every number it DIDN'T work out with, and a 1 under every number it DID work out with.


1024 512 256 128 64 32 16 8 4 2 1
0 0 0 0 1

Okay, I'm at 64 now. So I'd take 74 - 64 and get 10. So the remaining code has to somehow add up to 10.


1024 512 256 128 64 32 16 8 4 2 1
0 0 0 0 1 0 0 1 0 1 0

So my results got this:

00001001010

But, that's wrong. Because on this ASCII Binary chart I found online here, the actual binary code for it is:

01001010

Oh wow, I just realized my binary code is right except mine is 3 digits more, including the 0's on the left side.

Can anyone shed some light on this? I'm confusing myself more and more so I'm going to stop here. Was I on the right track?
 
Okay... I'm not really sure how that helps me.. ? Does that mean when I code something from ASCII to binary that I only count the first 8 digits starting from the right, THEN going left?
 
In terms of binary notation, 00001001010 = 01001010.
The number of leading zeros does not change the value. Suppose I tell you I'm going to write you a check for 5 dollars, but when I hand you the check, you see this value: $0005.00
Hopefully, you recognize that this is still only $5. Lame example, I know, but it helps illustrate my point.

1 = 01 = 001 = 0001 = 00001 = ...you get the point.
 
Status
Not open for further replies.
Back
Top Bottom