Results 1 to 15 of 15

Thread: How to convert Binary to Hex and Hex to Bin?!?

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    How to convert Binary to Hex and Hex to Bin?!?

    i want to know how to make it...i dont want vb functions..i want to know the threory behind it lol

  2. #2

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah and from binery to decimal and decimal o binary etc

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Ask the Wookie.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Well, you need to understand these are all "base" systems:

    Hex: Base 16
    Decimal: Base 10
    Binary: Base 2

    It's just a matter of conversion. I can go through it step by step. So, say, you have a number: 188. You want it in Binary.

    Find a power of 2 that is the highest that will fit into your number. For this, it would be 128. (2 to the 7th). Make 8 0's:

    0000 0000

    And since you can put 128 into 188, change the 1st 0 to a 1 and take away 128. It's now 60, and you have 128 taken away (show here):

    1000 0000

    You can put 32 (2 to the 5th) into it, so now change it to:

    1010 0000

    Now it's 28; you can put 16 (2 to the 4th) into it, so change it:

    1011 0000

    Now it's 12, you can put 2 to the 3rd (8) into it:

    1011 1000

    You've got 4, which is a power of 2. When your number IS a power of two, you can stop.

    1011 1100

    Therefore, decimal 188 in binary is:

    1011 1100.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Now let's convert 188 (decimal) to HEX.

    It's more difficult, so pay attention.

    Now that you have 188, find how many times 16 goes into it. For this number, it goes in 11 times (176). In Hex, 0 to 9 are shown normally, but it doesnt go over to the next column; it does so at 16. 10 is A, 11 is B, 12 is C, 13 is D, 14 is E, and 15 is F. Since we have 11 16's in 188, your first symbol will be 'B', and since it is under 256 (16 x 16), we know it must be 2 columns or under. Thus, we can add a 0:

    B0

    Now, the remainder is 12. Look at that mini-chart up there. 12 is C. Change the 0 to C:

    BC

    And that is 188 in Hex! A little more tricky, but still easy.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Conversion from Binary to Hex is quite simple.

    Did you see how I grouped my binary digits into 4's? I did that for a reason.

    1111 1111
    This is 255 in binary.

    FF
    Is 255 in Hex.

    1111 0000 1111
    This is 3855 in binary.

    F0F
    This is 3855 in Hex.

    See any resemblance? You should. For each grouping of 4, add 8 for the first digit, 4 for the 2nd, 2 for the 3rd, and 1 for the last. You should end up with a digit between 0 and 15. You can convert it to hex:

    0 - 0
    1 - 1
    2 - 2
    3 - 3
    4 - 4
    5 - 5
    6 - 6
    7 - 7
    8 - 8
    9 - 9
    10 - A
    11 - B
    12 - C
    13 - D
    14 - E
    15 - F

    Therefore 1111 becomes F, 1101 becomes D, 0101 becomes 5, etc. etc.

    For partial groups (ex. 3, 2, or 1 number), start from the right. So 1 number, that number is either 0 or 1, and the same in hex. 2 numbers can be 0, 1, 2, or 3. 3 numbers can represent 0 - 7.

    So, our example.

    1011 1100 is 188 in binary.

    Remember the grouping:
    8021 8400

    Now add up:
    11 12

    And convert with the chart.
    BC
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  7. #7
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    How about Hex to binary? Do a reverse lookup!

    0 - 0
    1 - 1
    2 - 2
    3 - 3
    4 - 4
    5 - 5
    6 - 6
    7 - 7
    8 - 8
    9 - 9
    10 - A
    11 - B
    12 - C
    13 - D
    14 - E
    15 - F

    So, BC.

    B = 11
    C = 12

    Convert 11 and 12 to binary:

    11:
    1000
    1010
    1011

    12:
    1000
    1100

    Therefore, BC in binary is 1011 1100.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Hex to decimal is easy! (aren't they all?)

    Simply do the reverse lookup, skipping conversion to binary.
    0 - 0
    1 - 1
    2 - 2
    3 - 3
    4 - 4
    5 - 5
    6 - 6
    7 - 7
    8 - 8
    9 - 9
    10 - A
    11 - B
    12 - C
    13 - D
    14 - E
    15 - F

    BC:

    B = 11
    C = 12

    But one thing you must remember, the rightmost character is multiplied by 16 ^ 0, the 2nd rightmost 16 ^ 1, the 3rd 16 ^ 2, etc. So:

    11 * 16 ^ 1 = 11 * 16 = 176
    12 * 16 ^ 0 = 12 * 1 = 12

    Now, add them up:

    176 + 12 = 188
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Now the last, binary to decimal.

    1011 1100

    As in the binary to hex example, value them:
    8021 8400

    And add them all up:
    11 12

    As in the hex to decimal example, multiply the rightmost by 16 ^ 0, the 2nd rightmost by 16 ^ 1, etc...

    11 * 16 ^ 1 = 11 * 16 = 176
    12 * 16 ^ 0 = 12 * 1 = 12

    And add those two together.

    176 + 12 = 188
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  10. #10
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Forum Feedback?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Originally posted by The Hobo
    Forum Feedback?
    Where's the predicate?

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  12. #12
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Hehe, I am the wookie
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  13. #13

  14. #14
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Whos the eggman then?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  15. #15
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Weird-asses.

Posting Permissions

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



Click Here to Expand Forum to Full Width