Binary and Hexadecimal
Results 1 to 9 of 9

Thread: Binary and Hexadecimal

  1. #1
    Member
    Join Date
    Feb 2003
    Posts
    78

    Binary and Hexadecimal

    Hey everyone,
    I just recently found out some pretty neat information about binary and hexadecimal. I would like to

    share my new found knowledge with the AO community. This information I am about to give you is coming

    from my new found knowledge. I used the book Sam's Teach Yourself C++ in 21 Days as a reference.

    First, in order to understand binary and hexadecimal, you must think of numbers, not as numbers, but as

    ideas. To help you understand what I mean, take the number 3 for example. The number three is an idea,

    while the numeral 3 is a symbol used to represent the number three. I am sure you know what I mean when I

    write ||| and III. Now that you think of numbers as ideas, we can change the way you see them.

    The numberal 15 is consisted of two numbers, 1 and 5. 1 meaning one set of tens, and 5 meaning five sets

    of ones. In base 10, you use the numerals 0,1,2,3,4,5,6,7,8,9. When you get to ten, you write 10. This

    means 1 set of tens and 0 sets of ones.

    Some basic rules can be made from this:
    1. Base 10 uses the digits 0-9
    2. Each column are powers of ten.

    Column: 4 3 2 1
    Power: 10^3 10^2 10^1 10^0
    Value: 1000 100 10 1

    So if you wanted to find the number 124, you would take 124/100=1 with a Remainder of 24. Now you have a

    1 in the third column. Then 24/10=2 with a Remainder of 4, so you would have a 2 in the second column.

    Last, take 4/1=4. Then you put all of the numbers to get 124.


    Binary
    Base 2 is the ultimate extension of this idea. There are only two different digits: 0 and 1.

    Column: 8 7 6 5 4 3 2 1
    Power: 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
    Value: 128 64 32 16 8 4 2 1

    *Note: Dont these numbers look familiar, maybe you have seen then while buying RAM?

    Ok, so lets convert the number 87 into binary.
    87/128 = 0. Put a 0 in column eight.
    87/64 = 1 with a Remainder of 23. Put a 1 in column seven.
    23/32 = 0. Put a 0 in column six.
    23/16 = 1 with a Remainder of 7. Put a 1 in column five.
    7/8 = 0. A 0 in column four.
    7/4 = 1 with a Remainder of 3. Put a 1 in column three.
    3/2 = 1 with a Remainder of 1. Put a 1 in column two.
    1/1 = 1, so put a 1 in the column one.

    When you write this out in binary, the columns go 87654321, so 87 in binary would be 01010111. Pretty

    neat, huh!


    Hexadecimal
    Since binary is very hard to understand and slow to read, we started looking for a simpler way to

    represent the same values. It turns out that it is very simple to translate base 2 to base 16, or

    hexidecimal. In base 16, there are sixteen numerals: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F. A would be the

    same as ten in base 10, as F would be the same as fifteen in base 10.

    Column: 4 3 2 1
    Power: 16^3 16^2 16^1 16^0
    Value: 4096 256 16 1

    To translate hexadecimal to base 10, you can multiply. Lets take F8C.
    F*256 (becuz F is in the third column) = 15*256 = 3840
    8*16 = 128
    C*1 (becuz C is in the first column) = 12*1 = 12
    F8C = 3980

    Now lets translate FC from hex into binary. Lets translate hex into base 10, and then base 10 into

    binary.

    F*16 = 15*16 = 240
    C*1 = 12*1 = 12
    FC = 252

    To translate 252 from base 10 into binary, you need the chart:

    Column: 8 7 6 5 4 3 2 1
    Power: 2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
    Value: 128 64 32 16 8 4 2 1

    252/128 = 1 with a Remainder of 124. Put a 1 in column eight.
    124/64 = 1 with a Remainder of 60. Put a 1 in column seven.
    60/32 = 1 with a Remainder of 28. Put a 1 in column six.
    28/16 = 1 with a Remainder of 12. Put a 1 in column five.
    12/8 = 1 with a Remainder of 4. Put a 1 in column four.
    4/4 = 1 with a Remainder of 0. Put a 1 in column three.
    Becuz the Remainder is 0, there is nothing left, and the last two digits are 0's
    FC = 252 = 11111100

    Now for the trick that makes base 2 and base 16 work together so nicely.
    If you treat this number as two sets of four digits, you have 1111 1100.
    Take the left set and translate it into base 10. 1111 = 15. Translate 15 into hex and you get F.
    Take the right set and translate it into base 10. 1100 = 12. Translate 12 into hex and you get C.
    1111 1100
    F C

    Putting the two hex numbers together is FC. In binary it is 11111100 and in base 10 it is 252. This trick

    always works. You will find out that alot of programmers use hex frequently in advanced programming,

    although you can work effectively in programming for a long time without using any of this.

    I hope that some of you will learn something, as I have. Any errors I missed feel free to correct.

    -Ep
    01001001001000000100110001101111011101100110010100100000010000100110010101110100011101000111100100100001
    Share on Google+

  2. #2
    Super Moderator
    Know-it-All Master Beaver

    Join Date
    Jan 2003
    Posts
    3,914
    Good lord!

    Do you people not know how to search? There have already been SEVERAL tutorials posted on the various numbering systems and how to convert between them. I suggest you have someone delete this because it's rather irritating to see the same stuff posted again and again. Do a search before you post something in the future.
    IT Blog: .:Computer Defense:.
    PnCHd (Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".
    Share on Google+

  3. #3
    Senior Member
    Join Date
    May 2002
    Posts
    344
    HTRegz does have a point, but come on peoples, he is a AO newbie and this is his first tutorial. Anyways, although tuts like this one have been posted multipule times before, it was a good tutorial and i feel like it got the message accross...next time though, do a search and see if people have already written about what you are planning on writing about...also, good job when it comes to siteing sources, most newbies forget to do that
    Support your right to arm bears.


    ^^This was the first video game which i played on an old win3.1 box
    Share on Google+

  4. #4
    Super Moderator
    Know-it-All Master Beaver

    Join Date
    Jan 2003
    Posts
    3,914
    Originally posted here by White_Eskimo
    HTRegz does have a point, but come on peoples, he is a AO newbie and this is his first tutorial. Anyways, although tuts like this one have been posted multipule times before, it was a good tutorial and i feel like it got the message accross...next time though, do a search and see if people have already written about what you are planning on writing about...also, good job when it comes to siteing sources, most newbies forget to do that
    Even if he is stay an AO newbie from lack of posts, he has been here since feb. which is nearly as long as I've been here. That's plenty of time to learn the rules and read the FAQs... The fact that it's his first tutorial has nothing to do with it, he should have read and looked before putting it up.. regardless.
    IT Blog: .:Computer Defense:.
    PnCHd (Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".
    Share on Google+

  5. #5
    Banned
    Join Date
    Jun 2003
    Posts
    1,302
    Yeah I think the Guy got the point. Let him mark it up as a learning Experience
    Share on Google+

  6. #6
    Member
    Join Date
    Feb 2003
    Posts
    78
    Thanks to those of you who gave me positive antipoints, and to the one and only one who has ever giving me negitive antipoints, thanks alot.
    I would like to say, That after I read the section on in my book on Binary and Hex, I came to the computer and started this tut. When I finished it I posted it right on the site. No I didnt do a search. Maybe I should have, but just now I did do a search and look what I found.

    http://www.antionline.com/search.php...der=descending

    That is all. I type in the search window "Binary OR Hexadecimal OR Hex" and that is all I found in the tut. forum. Maybe I am not using the search engine right. If I am using it wrong, I am sorry. Otherwise, back off man.

    -Ep
    01001001001000000100110001101111011101100110010100100000010000100110010101110100011101000111100100100001
    Share on Google+

  7. #7
    Senior Member
    Join Date
    Jul 2002
    Posts
    744
    AO search isn't the best, I agree, best way to look is to go to the tutorials forum and actually browse what's been posted. Time consuming, I know, but it does give you a good idea of what people here have to offer. I would have personally written a few tutorials a long time ago, but everything I would have written has already been done and I hate redundancy. It was a good tut, though.

    ~edit~ As a side note, it is a pain having to browse through all of the tuts, but if you read through them, you might see something that they have missed or didn't present as clearly as you might have been able too on the topic. . . then when you write your tut, you have a solid reason and we all benefit from your knowledge.
    Every now and then, one of you won't annoy me.
    Share on Google+

  8. #8
    Just a Virtualized Geek MrLinus's Avatar
    Join Date
    Sep 2001
    Location
    Redondo Beach, CA
    Posts
    7,324
    If I may suggest, for yourself and others to check Negative's Tutorial Index Page. It lists all the tutorials up to June of this year (Neg, might be worthwhile to update.. .. ). Simple browser find option will show you which tutorials exist with similar topics.

    And with that.. *CLOSED*
    Goodbye, Mittens (1992-2008). My pillow will be cold without your purring beside my head
    Extra! Extra! Get your FREE copy of Insight Newsletter||MsMittens' HomePage
    Share on Google+

  9. #9
    Banned
    Join Date
    Aug 2001
    Location
    Yes
    Posts
    4,429
    It's been updated, MsMittens
    Share on Google+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides