Hexadecimal notation (base sixteen) is used throughout the Web and computer systems to indicate values. One good example is the notation for color in HTML pages. Reading and using hexadecimal takes some practice, but the basic concept is no more difficult to understand than the ordinary decimal (base ten) system you've been using all your life.
Steps
-
Learn what hexadecimal is. Just like the decimal number system uses ten different symbols to denote values from Zero to Nine , the hexadecimal number system uses sixteen different symbols to denote values from Zero to Fifteen . Any number can be written in either system. [1] X Research source Here's how to start counting in hexadecimal:
- zero through fifteen: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
- sixteen through thirty-two: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20
-
Learn how to write bases. The ten symbols used in the decimal number system form the base of the decimal number system. [2] X Research source Similarly, the sixteen symbols used in the hexadecimal number system form the base of the hexadecimal number system. Whenever it's unclear which base is being used, subscript numbers are added to show the base. For example, 100 10 is "100 in base 10" and 100 16 is "100 in base 16" (which equals 256 10 ).
- Another term for "base" is "radix" (pluralized "radixes" or "radices").
Advertisement -
Understand place values in decimal. We can understand long numbers written in base 10 without even pausing to think, but that's only because we've had a lot of practice. [3] X Research source We know automatically that "5834 10 " means 5x10 3 + 8x10 2 + 3x10 1 + 4x10 0 . Each digit in a multi-digit number has its own place value. Here are the place values in decimal, from right to left:
- 10 0 10 = 1
- 10 1 10 = 10 10
- 10 2 = 10x10 = 100
- 10 3 = 10x10x10 = 1000
- 10 4 = 10x10x10x10 = 10000
- 10 5 = 10x10x10x10x10 = 100000 & so on.
-
Learn the hexadecimal place values. Since hexadecimal is base sixteen, the place values are based on powers of sixteen, not powers of ten. Here are the powers of sixteen, written in decimal. [4] X Research source
- 16 0 10 = 1
- 16 1 10 = 16 10
- 16 2 =16x16= 256
- 16 3 =16x16x16= 4096
- 16 4 =16x16x16x16= 65536
- 16 5 =16x16x16x16x16= 1048576 & so on.
- If we write these in hexadecimal, these would instead be written as 10 16 , 100, 1000, etc.
-
Convert from hexadecimal to decimal. Converting between two bases is a good way to become familiar with how each system works. Here's how to convert from any number in hexadecimal to the same number written in decimal: [5] X Research source
- Write out your hexadecimal number: 15B30 16
- Write each digit out as a decimal multiplication problem, using the place value in the chart above: 15B30 = (1 x 65536 10 ) + (5 x 4096 10 ) + (B x 256 10 ) + (3 x 16 10 ) + (0 x 1)
- Convert non-decimal symbols into decimal numbers. In our example, B = 11 10 , so that digit can be converted to 11 10 x 256 10
- Solve the problem. Use a calculator or work it out by hand, and you'll get the answer in decimal. 15B30 = 65536 + 20480 + 2816 + 48 + 0 = 88880 10
-
Understand how colors on a computer screen are determined. All colors on a computer screen are determined by three values: red, green, and blue. All colors of light can be created by combining these three types of light in different proportions. On a computer screen, red, green, and blue can each be assigned any value from 0 to 255 (for a total of 256 possible values). [6] X Research source
- This doesn't match the "primary" colors you learned in school, because that color system is based on physical pigment (like paint), not light. The paint system is sometimes called "subtractive color system" and the light system (the RGB system described here) "additive."
-
Learn why hexadecimal is used for colors. HTML uses hexadecimal to describe colors. This is convenient, since a two-digit hexadecimal number can communicate exactly 256 10 possible values. This isn't a coincidence; the number 256 10 is due to limitations of old hardware, which could only handle 100000000 2 colors, or 256 10 . Because 2 4 = 16 10 , any binary system can be easily converted to a hexadecimal system with ¼ as many digits.
- The subscript numbers tell you which base the numbers is written in. Base 2 is binary, base 10 is ordinary decimal, and base 16 is hexadecimal.
-
Understand how the system works. The hexadecimal color system is easy to understand, once you know how it works. The first two digits are the red value, the next two are the green value, and the last two are the blue value. [7] X Research source Here are some examples:
- #FFFFFF is white, while #000000 is black.
- Any color with equal r, g, and b values (besides black and white) is a shade of grey, such as #121212, #5A5A5A, or #C0C0C0
- #003000 is a very dark green. #003F00 is barely any lighter (you've only added F, or 16 10 green), but #00FF00 is the brightest possible green (adding an additional C0, or 192 10 ).
- More complex colors are created by using all three types of light. Try to guess #7FFFD4, #8A2BE2, or #A0522D.
-
Teach yourself to read hexadecimal intuitively. Use the examples below as "milestones" to help you estimate the size of a hexadecimal number. This will give you a more intuitive understanding of hexadecimal, and let you read hexadecimal numbers without laboriously converting to decimal every time. As you'll see, one advantage to hexadecimal is that the number of digits doesn't increase nearly as fast as it does in decimal:
- Humans have A fingers, or 14 16 if you count the toes too. (Remember, the subscript 16 means a number is written in base sixteen.)
- In a residential area, drive below 19 16 miles per hour (or 28 16 kilometers per hour).
- A typical highway driving speed is 3C mph (or 64 16 kph).
- Water boils at D4 ºFahrenheit (64 16 º Celsius).
- The median U.S. income is roughly C350 dollars a year.
- The population of the world is over 1A0,000,000.
-
Learn hexadecimal addition. You can do hexadecimal addition problems without ever converting to another system. It does take some mental effort and practice to remember the new rules. Here are a few methods and tips: [8] X Research source
- Count up one by one, using hexadecimal digits. For instance to solve 7+5 in hex, count 7, 8, 9, A, B, C .
- Carry the one when needed. If your addition gets you past F, you "carry the one" as you would in a normal addition problem. For example, A+5 = F, A+6 = 10 16 , A+7 = 11 16 , and so on. Similarly, 3A+6 = 40 16 , 3A+7 = 41 16 , etc.
-
Learn hexadecimal multiplication. Just like regular multiplication, the best way to become competent at hexadecimal multiplication is to memorize the multiplication tables. Here's the hex "6 times table" as an example (all numbers are hexadecimal): [9] X Research source
- 6 x 1 = 6
- 6 x 2 = C
- 6 x 3 = 12
- 6 x 4 = 18
- 6 x 5 = 1E
- 6 x 6 = 24
- 6 x 7 = 2A
- 6 x 8 = 30
- 6 x 9 = 36
- 6 x A = 3C
- 6 x B = 42
- 6 x C = 48
- 6 x D = 4E
- 6 x E = 54
- 6 x F = 5A
Community Q&A
-
QuestionHow did this work in the movie The Martian as satellite communication?Community AnswerASCII was used; it is the American Standard Code for Information Interchange. For example, 6E was the lowercase letter "n" and 6F was the lowercase letter "o." Combining these gives us 6E6F for "no."
-
QuestionConvert the decimal number 64 to hexadecimal.DonaganTop AnswererIt's 40, which indicates 4 sixteens and zero ones.
Tips
- Any binary number can be easily represented in hexadecimal. Divide the binary number into four-digit sections (adding initial 0s if necessary), then replace each section with the equivalent hexadecimal digit. For example, 0000 2 = 0 16 , 0001 2 = 1 16 ... all the way up to 1111 2 = F 16 . [10] X Research sourceThanks
- You can use an online base conversion calculator to convert between binary, decimal, and hexadecimal.Thanks
- Computers actually use the "complement" method to add and subtract numbers (in hexadecimal or any other base), not the "carrying" method we're used to. The complement method is not a very useful method for humans, but if you program calculating software, you should learn it to make your program more efficient.Thanks
Video
References
- ↑ https://www.cuemath.com/numbers/hexadecimal-number-system/
- ↑ https://www.mathsisfun.com/definitions/radix.html
- ↑ https://www.mathsisfun.com/hexadecimals.html
- ↑ https://www.mathsisfun.com/hexadecimals.html
- ↑ https://www.rapidtables.com/convert/number/hex-to-decimal.html
- ↑ https://www.mathsisfun.com/hexadecimal-decimal-colors.html
- ↑ https://www.mathsisfun.com/hexadecimal-decimal-colors.html
- ↑ https://www.calculator.net/hex-calculator.html
- ↑ https://www.calculator.net/hex-calculator.html
About This Article
To understand hexadecimal, first learn that in this number system there are 16 different symbols used to denote values from 0 to 15. The 16 symbols used in the hexadecimal number system form the base. Since hexadecimal is based on 16, the place values are based on powers of 16. To convert from hexadecimal to decimal, write out the hexadecimal number, convert non-decimal symbols into decimal numbers, and solve the problem. To learn how to understand the hexadecimal color system, keep reading!
Reader Success Stories
- "Clear and concise. Really helpful for someone completely unfamiliar with different number systems."