Idea Transcript
More Next Blog»
Create Blog Sign In
THE DIGITAL VOICE NE WS RE L A TI NG TO P RO G RA MMI NG , NE TWO RK S E CURI TY , A ND TE CHNO L O G Y
THURSDAY, FEBRUARY 2 3 , 2 0 0 6
SUBSCRIBE TO
Why do we use Hexadecimal?
Posts
Thanks to OSNews.com for pointing out this site aimed at teaching C. While the site is still too new and the number of articles there are too few in
Comments
number to really indicate if the authors efforts are worthwhile, but I enjoyed reading the articles and I feel he is heading in the right direction. However, whenever I come across a programming tutorial, I always find one thing
FO L L O WE RS
glaringly omitted when talking about hexadecimal numbers. So much time is spent on how to work with them, but very rarely does anyone ever say why. And I find that strange. Its almost like your just expected to accept it, without any real knowledge as to why your working with a number system that is not the same as the number system that was crammed down your throat almost all your life. The main reason why we use hexadecimal numbers is because it is much easier to express binary number representations in hex than it is in any other base number system. Computers do not actually work in hex (don’t laugh, beginning students do ask that question). Lets look at an example, using a
TWI TTE R
byte. Bytes are typically 8 bits, and can store the values 0 – 255 (0000 0000 – 1111 1111 in binary). For people, expressing numbers in binary is not convenient. I am not going to turn around to my co-worker and tell him that my phone number is 101 101 101 001 010 001 010 for obvious reasons. Imaging having to try and work with that on a daily basis. So a more convenient expression is needed for the human side.
A B O UT ME J O HN WARD
I am a computer programmer by trade, and a fitness enthusiast. I have been
Since a byte is 8 bits, it makes sense to divide that up into two groups, the top 4 bits and the low 4 bits. Since 4 bits gives you the possible range from 0 – 15, a base 16 system is easier to work with, especially if you are only familiar with alphanumeric characters (I don’t know of any languages have 255 letters in their alphabet, but I am naive and not worldly). It’s easier to express a binary value to another person as “A” then it is to express it as “1010”. This way I can simple use 2 hex values to represent a byte and have it work cleanly. This way if I am piss poor at math, I only need to memorize the multiplication tables up to 15. So if I have a hex value of CE, I can easily determine that 12 * 14 = 206 in decimal, and can easily write it out in binary as 1100 1110. Trying to convert from binary would require me to know what each place holder represents, and add all the values together
writing about programming for several years, and am the author of "Practical Data Analysis and Reporting with BIRT" and "BIRT 2.6: Data Analysis and Reporting". I am a full time consultant specializing in Business Intelligence, enterprise search, and eCommerce. I do Gracie Jiu-Jitsu, P90X, and Insanity. I am a BeachBody coach and reseller for P90X, Insanity, and Shakeology. V I E W MY CO MP L E TE P RO FI L E
(128 + 64 + 8 + 4 + 2 = 206). It’s much easier to work with binary through hex than any other base system. Further reading available here.
BL OG ARCHIVE
Octal comes into a close second. In octal, you can represent, at most, 3 bits
2014 (2)
with a single octal digit. So its very easy to say 311 is 11 001 001. The
2013 (4)
problem with octal, as you can see, is that the 3rd octal digit can only goes
2012 (9)
as high as 3, so it does not represent a byte as cleanly as hex. Octal is used in Unix for permissions due to its 3-bit nature. If we take the three specific
2011 (11)
entitlements (read, write, execute) for a file, we find that it coincides very
2010 (14)
well with octal. That’s why you see those really funky “chmod 744”
2009 (22)
commands, because they are octal representation of permissions, 111 100
2008 (30)
100, or R-W-E, Read, Read for owner, group, world respectively (at least that is how it was explained to me). The leftmost bit represents the read flag, the middle one represents the write flag, and the rightmost flag represents
2007 (47) t 2006 (139)
execute. So if you wanted the permission for read-write, it would be 110, or
December (7)
6. Read and execute would be 101 or 5.
November (10)
Incidentally, there is such a thing as a binary coded decimal. Binary coded
October (17)
decimals are used more for our convenience than for the machines. I have
September (12)
seen BCD more often in electronic circuits using 7 segment displays, and
August (5)
various encoding methods used in PC’s. In BCD, 4 bit patterns are used to
July (23)
represent one base 10 digit. Once the value 9 is represented, another 4 bits are allocated. To compare, the value 10 in straight binary is 1010, where as
June (11)
in BCD it is 0001 0000. Another example is in straight binary, 29 is
May (9)
represented as 0001 1101. In BCD it is 0010 1001.
April (12)
P O S TE D B Y J O HN WA RD A T 1 1 : 3 1 A M
March (14)
t February (11) RSS Feeds Added 1 0 COMME NT S:
ASM Using Debug to Find Video Card Manufacturer
Anonymous said... Is here any number system, which is better than hexadecimal? Or will it be?
ASM Hello World
3 : 2 6 PM
Why do we use Hexadecimal? Asm: Retrieve 3 Key Strokes And Display The Result...
Anonymous said...
Popup Windows Passing Data back to Parent Web Page...
12 x 14 = 168. I have the same issues. 6 : 1 6 PM
ADO Data Control and Oracle Sequences
Anonymous said...
Actuate e-Spreadsheet Report
Not quite so easy:
VMWare Server Beta Released (12 x 16) + 14 = ...
VmWare for Free?
9 : 5 5 PM
Coldfusion Development Part 1 January (8)
Anonymous said...
2005 (48)
I had been wondering about this for quite a while. Thanks! 1 2 : 1 0 AM Rakesh R said... probably i am dumb but i still dont get the point. You said : "The main reason why we use hexadecimal numbers is because it is much easier to express binary number representations in hex than it is in any other base number system" and also : "It’s easier to express a binary value to another person as “A” then it is to express it as “1010”. Why not use 10 instead of A to represent 1010. point is i think it is easier to represent binary in decimal format than any other number system. 7 : 4 4 AM Nicholas said... Not exactly. 3A2D is easy to convert mentally. 3 is 0011, A is 1010, 2 is 0010, D is 1101. The final answer is 0011 1010 0010 1101. I have no clue what that is in decimal, however. 1 2 : 0 4 AM Anonymous said... You asked "Why not use 10 instead of A to represent 1010. point is i think it is easier to represent binary in decimal format than any other number system." Because it is not a base 2 (binary) system and therefore harder to convert. 2 : 2 6 PM mame said... 1.why a group of 4 binary digits one hexadecimal digit? 2.why a group of 3 binary digits one octal digit? 1 1 : 2 7 PM Anonymous said... Haha your number is 555-1212 great reference! 1 0 : 2 5 PM Vanapapi said... Shortly: I think it's easier to human in hexadecimal. EXPLAINED: I think it's because you can form 15 different variations from four bits and with hex you represent each nibble(four bits) with one number or letter. For example: 0011 1100 1110, which in hex is 3CE, because 0011=3 1100=C and 1110=E. Easy with the help of a chart like this http://www.ee.nmt.edu/~rison/ee308_spr00/supp/000119/dec_hex_bin.gif . It gets more complicated if you try to convert it into decimal, because there are more combinations with four 0's and 1's then there are numbers in decimal and you have to use formulas to get the number, which is 974 by the way. THE POINT IS YOU JUST CAN*T TAKE NUMBERS LIKE 1100 1110 (CE) AND SAY IT IS 12*14=168, BECAUSE ITS 206 AND YOU NEED FORMULAS TO FIGURE IT OUT, BUT YOU CAN SAY IT'S CE. A very good video which explains the same thing: http://www.youtube.com/watch?v=9xbJ3enqLnA Hope I helped. 1 : 2 0 PM Post a Comment Newer Post
Home
Subscribe to: Post Comments (Atom)
Older Post