Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » How do you code in binary from ASCII?
Closed Thread
Old 08-11-2006, 02:57 AM   #1 (permalink)
 
Monster Techie

Join Date: Sep 2005

Location: /home/jason

Posts: 1,823

Jayce will become famous soon enoughJayce will become famous soon enough

Send a message via AIM to Jayce
Default How do you code in binary from ASCII?

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?
__________________
Go open source, or go home.
Jayce is offline  
Old 08-11-2006, 09:55 AM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

ASCII characters are 1byte in size, therefor there will only be 8 bits in each character.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 08-11-2006, 10:23 AM   #3 (permalink)
 
Monster Techie

Join Date: Sep 2005

Location: /home/jason

Posts: 1,823

Jayce will become famous soon enoughJayce will become famous soon enough

Send a message via AIM to Jayce
Default

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?
__________________
Go open source, or go home.
Jayce is offline  
Old 08-11-2006, 11:17 AM   #4 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default

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.
jaeusm is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On