Decimal vs. Hex

This is a discussion on Decimal vs. Hex within the C Programming forums, part of the General Programming Boards category; In a lot of source code i've seen i've noticed that most authors use a lot of hex numbers in ...

  1. #1
    Registered User -leech-'s Avatar
    Join Date
    Nov 2001
    Posts
    54

    Question Decimal vs. Hex

    In a lot of source code i've seen i've noticed that most authors use a lot of hex numbers in their work. What i want to know is, why hex? I've been programming for a little over a year so i'm familiar with what it is and HOW to use it, but WHY? I've heard that it's faster than decimal because it's a power of 2 (2^4) but in modern day compilers does that really make a difference?

    Thanks.
    Not yet, have to think of one...

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Hexadecimal numbers are numbers with base 16 and they are in many cases used since conversion from binary number to hexadecimal number is very easy.

    0000 - 1
    0001 - 2
    0010 - 3
    0011 - 4
    0100 - 5
    0101 - 6
    0110 - 7
    0111 - 8
    1000 - 9
    1001 - A
    1010 - B
    1011 - C
    1100 - D
    1101 - E
    1110 - F
    1111 - G

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    That's stupid isn't it? :-)

    0000 - 0
    0001 - 1
    0010 - 2
    0011 - 3
    0100 - 4
    0101 - 5
    0110 - 6
    0111 - 7
    1000 - 8
    1001 - 9
    1010 - A
    1011 - B
    1100 - C
    1101 - D
    1110 - E
    1111 - F

    Dutch mathematics, 0 == 1. :-)

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    43

    Thumbs up

    _Bin___HEX
    1111 = 10
    ()()() MonKey ware
    Kyle J. R.

  5. #5
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Can't tell Shiro's a programmer - he can't decide whether to start counting with 0 or 1

  6. #6
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368
    Originally posted by Goof Program
    _Bin___HEX
    1111 = 10
    _Bin___HEX
    1111 = F

  7. #7
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >Can't tell Shiro's a programmer - he can't decide whether to >start counting with 0 or 1

    Well, it is very confusing. I once went to the store around the corner to buy some apples. Counting, 0, 1, 2, 3. So I told the girl in the store that I had 3 apples, she didn't believe me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Decimal to Hex Converter
    By rocketman03 in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:50 AM
  2. Replies: 11
    Last Post: 03-24-2006, 10:26 AM
  3. hex to binary,hex to decimal
    By groovy in forum C Programming
    Replies: 2
    Last Post: 01-25-2006, 01:14 AM
  4. Converting decimal to hex
    By cobrakidd in forum C++ Programming
    Replies: 9
    Last Post: 02-06-2003, 10:37 AM
  5. about decimal to hex progam
    By Abdi in forum C Programming
    Replies: 2
    Last Post: 06-01-2002, 07:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21