Hexadecimal: Difference between revisions

From Rosetta Code
Content added Content deleted
m (Should have previewed)
mNo edit summary
Line 1: Line 1:
[[Category:Encyclopedia]]Hexadecimal code is another number system used by computers. While decimal (our normal number system) uses ten digits, and binary uses two digits (0 and 1), hexadecimal uses base 16.
[[Category:Encyclopedia]]Hexadecimal code is another number system used by computers. While decimal (our normal number system) uses ten digits, and binary uses two digits (0 and 1), hexadecimal uses base 16.


Instead of using only 0's and 1's like binary, or 0-9 like decimal, hexadecimal uses 0-9 just like base 10, but also A-F. A=10, B=11, and so forth. The most convenient method of converting binary to hexadecimal is to first separate the binary number into string of 4 digits. Then, convert each group into base 10, at which point 10-15 are changed into letters.
Instead of using only 0's and 1's like binary, or 0-9 like decimal, hexadecimal uses 0-9 just like base 10, but also A-F. A=10, B=11, and so forth. The most convenient method of converting binary to hexadecimal (for a human) is to first separate the binary number into string of 4 digits. Then, convert each group into base 10, at which point 10-15 are changed into letters.


Ex.
Ex.

Revision as of 03:04, 31 January 2009

Hexadecimal code is another number system used by computers. While decimal (our normal number system) uses ten digits, and binary uses two digits (0 and 1), hexadecimal uses base 16.

Instead of using only 0's and 1's like binary, or 0-9 like decimal, hexadecimal uses 0-9 just like base 10, but also A-F. A=10, B=11, and so forth. The most convenient method of converting binary to hexadecimal (for a human) is to first separate the binary number into string of 4 digits. Then, convert each group into base 10, at which point 10-15 are changed into letters.

Ex.

     10010111
   1001   0110
2^3+2^0   2^2+2^1+2^0
8+1        4+2+1
  9          7
       97