Public Group

Archived

This topic is now archived and is closed to further replies.

I want to change words to binary number , Can you help me please !!!

This topic is 5421 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I want to change words to binary number .... That words is "Bug" so You explain to me for about How to change word to binary number ? Thank you very much ...

Share on other sites
ASCII -> Binary.
Hmm.. I''m just thinking, maybe you can use the %-operator to do it.
letter%1 = binary value 0
letter%2 = binary value 1
letter%4 = binary value 2

I could be wrong. Let''s see what others say.

--
You''re Welcome,
Rick Wong
- sitting in his chair doing the most time-consuming thing..

Share on other sites
Why? Anyway, if you just search google for binary translator you are bound to find several sites that convert between ASCII text to binary. If you are interested in actually learning binary there are plenty of tutorials out there, once again just search google.

Edit: Pipo - I've never heard of doing it that way, and I'm not sure that its even legal because you compare a string to an int.

Edit Again: You may want to search for assembly tutorials, many of them have an entire section dedicated to binary and hexadecimal and converting betweent he two and binary.
[edited by - Aerolithe on October 15, 2003 2:42:35 PM]

[edited by - Aerolithe on October 15, 2003 2:46:34 PM]

Share on other sites

1) For each letter, find the ASCII key code #. That is,

B = 66
u = 117
g = 103

2) Then, convert each of those decimal numbers to binary:

B = 1000010
u = 1110101
g = 1100111

3) Pad these out to make sure you have 8 bits per character (since ASCII key codes are 8 bits per)

B = 01000010
u = 01110101
g = 01100111

4) Then, put these binary numbers together in proper order:

Bug = 01000010 01110101 01100111   or 010000100111010101100111

Note that you can decode that back into Bug by:

a) Break the binary version into 8-bit blocks
b) For each 8-bit block, convert the binary to decimal
c) For each decimal #, lookup the character in an ASCII table.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share on other sites
quote:
Original post by Aerolithe
Edit: Pipo - I''ve never heard of doing it that way, and I''m not sure that its even legal because you compare a string to an int.

I think by letter he means a char, which is really an int type (just 1 byte instead of 2 or 4 or 8).

But, that method won''t give a unique result.
There may be other words that produce the same result.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share on other sites
quote:
Original post by grhodes_at_work
quote:
Original post by Aerolithe
Edit: Pipo - I''ve never heard of doing it that way, and I''m not sure that its even legal because you compare a string to an int.

I think by letter he means a char, which is really an int type (just 1 byte instead of 2 or 4 or 8).

But, that method won''t give a unique result.
There may be other words that produce the same result.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Yeah, wasn''t paying attention while I was reading. And modulus wont work because of the fact that lots of letters will give the same result, maybe you are thinking of some bitwise operators?

Share on other sites

(thing & (1 << x))

will tell you if bit x in ''thing'' is a 1, where the bits are counted right-to-left and the rightmost is bit 0.

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 18
• Forum Statistics

• Total Topics
632160
• Total Posts
3004500

×