Why Do People Use Hexadecimal? (2024)

CS 100 (Learn)CS 100 (Web)Module 01

(direct YouTube link)

NOTE: If your internet access is restricted and you do not have access to YouTube, we have provided alternate video links.

TRANSCRIPT

Hexadecimal (or just "Hex" for short) is the name of the number system with base 16, and it is very popular in the world of computers, for reasons that we will see in this video.

First, let's review the first sixteen numbers, written in decimal, binary and hex:

| Decimal | Binary | Hex ||---------|--------|-----|| 0 | 0000 | 0 || 1 | 0001 | 1 || 2 | 0010 | 2 || 3 | 0011 | 3 || 4 | 0100 | 4 || 5 | 0101 | 5 || 6 | 0110 | 6 || 7 | 0111 | 7 || 8 | 1000 | 8 || 9 | 1001 | 9 || 10 | 1010 | A || 11 | 1011 | B || 12 | 1100 | C || 13 | 1101 | D || 14 | 1110 | E || 15 | 1111 | F |

Again, this table will be provided on exams.

As you can see from this table, each hex digit corresponds to exactly four binary digits.

To convert back and forth between binary (or base two) and hexadecimal (base sixteen) is actually quite easy.

To convert from binary to hex, you want to:

  • partition the number in to groups of four, starting on the right
  • convert each group of four binary digits to hex

If we have the number one one one one zero one one zero zero base two [1111011002], we group the number into fours, starting on the right.

1 1110 1100

We then convert each group of four to hex, using our table.

one one zero zero becomes C, one one one zero becomes E and zero zero zero one becomes one. So the equivalent number is one E C base sixteen [1EC16].

To convert from hex to binary, you just reverse the process.

It is good to start on the right, for consistency.

If we have the number three F B in hex [3FB16]:

B becomes one zero one one, F becomes one one one one, and three becomes zero zero one one.

Reading from left to right, we see that three F B in hex [3FB16] becomes one one one one one one one zero one one in binary [11111110112].

The reason hex is so popular in the world of computers is because it is so easy to convert back and forth between binary and hex.

Hex is much more compact than binary and it makes it much more practical and less overwhelming to use.

Because each byte is exactly eight binary digits, that means each byte is always exactly two hex digits. That makes it really easy to identify how many bytes of information a number is, and what those bytes are.

It is much harder to look at a decimal number and break it into bytes. In addition, representing values in decimal sometimes hides information that is clearer in hex. The numbers forty thousand nine hundred and sixty and forty-one thousand one hundred and fifty-two [4096010, 4115210] don't look that similar in decimal, but in hex they are A zero zero zero and A zero C zero [A00016 and A0C016]. That's not very important in this course, but in in some contexts that could be quite helpful.

In practice, it's not always feasible to use subscripts to indicate that a number like one two three four is in hex [123416], and so there are two common conventions to indicate a number is in hex. Programmers often use the prefix "zero x" before the number, so it would become "zero x one two three four" [ 0x1234 ]. Web designers use the number sign or the "hashtag" prefix \so it would become hashtag one two three four [ #1234 ]. This is easy to remember because a "hashtag" looks a bit like an H.

So if you want to let someone know they are important to you, you can tell them two thousand nine hundred and ninety [2,990], which in hex becomes "hashtag" BAE.

Why Do People Use Hexadecimal? (2024)

FAQs

Why Do People Use Hexadecimal? ›

Hex numbers are compact and use less memory, so more numbers can be stored in computer systems. Their small size also makes input-output handling easier compared to other numbering formats. Because it's easy to convert hexadecimal to binary and vice versa, the system is widely used in computer programming.

Why do humans use hexadecimal? ›

Hex is useful because large numbers can be represented using fewer digits. For example, colour values and MAC addresses are often represented in hex. Additionally, hex is easier to understand than binary. Programmers often use hex to represent binary values as they are simpler to write and check than when using binary.

What is the reason for hexadecimal? ›

The advantage of using hexadecimal rather than decimal increases rapidly with the size of the number. When the number becomes large, conversion to decimal is very tedious. However, when mapping to hexadecimal, it is trivial to regard the binary string as 4-digit groups and map each to a single hexadecimal digit.

What are the 4 main uses of hexadecimal? ›

There are many uses of hexadecimal in computers:
  • Memory addresses and other hardware related values.
  • Representation of colour values.
  • Error messages.
  • Memory dump.
  • Debugging.
  • IP addresses.
  • ASCII / Unicode.
  • Assembly language.

How is hexadecimal used in everyday life? ›

For example, hexadecimal is used to denote colors in the “hex” scheme. For memory readouts, values are also often in hexadecimal. Even braille is coded in hexadecimal. There are a couple obvious reasons why hexadecimal is preferable to the standard binary that computers store at the low level.

What is the benefit of using hexadecimal? ›

Hex numbers are compact and use less memory, so more numbers can be stored in computer systems. Their small size also makes input-output handling easier compared to other numbering formats. Because it's easy to convert hexadecimal to binary and vice versa, the system is widely used in computer programming.

Why are hex codes useful? ›

Hex codes are a hexadecimal format for identifying colors. This is a system used in HTML, CSS and SVG. Each hex code refers to a very specific color, which allows for two designers or a designer and developer to be on the same page about what exact light blue (or any other color) they are referring to.

Why is hexadecimal more efficient? ›

A more efficient method is to use hexadecimal (base 16). One hex digit represents any whole number between 0 an 15. So eight digits of binary can be translated into two digits of hexadecimal, which is much easier and much less error-prone for humans.

Why do we study hexadecimal? ›

Many technical people believe that hexadecimal numbers are the advanced version of binary numbers. Many modern organizations have also started using hexadecimal numbers in place of zeros and ones. Along with that, hexadecimal numbers are also used to enhance the security of a website.

Who invented hexadecimal? ›

In 1859, Nystrom proposed a hexadecimal (base 16) system of notation, arithmetic, and metrology called the Tonal system.

Do computers understand hexadecimal? ›

Yes they can. Optical character recognition is a thing. Otherwise, we think of computers as reading binary values, we group the bits into bytes and label the enumeration as hexadecimal, but it could just as easily be "binary" or "octal". In reality computers often read non-binary values.

What can you do with hexadecimal? ›

Hexadecimal can be used to write large binary numbers in just a few digits. It makes life easier as it allows grouping of binary numbers which makes it easier to read, write and understand. It is more human-friendly, as humans are used to grouping together numbers and things for easier understanding.

What is the difference between hex and hexadecimal? ›

The hexadecimal numeral system, often shortened to "hex", is a numeral system made up of 16 symbols (base 16). The standard numeral system is called decimal (base 10) and uses ten symbols: 0,1,2,3,4,5,6,7,8,9. Hexadecimal uses the decimal numbers and six extra symbols.

What are the current uses of hexadecimal? ›

Hexadecimal is used extensively in assembly programming languages and in machine code. It is often used to refer to memory addresses. It can be used during the debugging stage of writing a computer program and to represent numbers stored in a CPU's registers or in main memory.

What is an example of a hex code? ›

HEX Color Values

For example, #ff0000 is displayed as red, because red is set to its highest value (ff), and the other two (green and blue) are set to 00. Another example, #00ff00 is displayed as green, because green is set to its highest value (ff), and the other two (red and blue) are set to 00.

How to read hex? ›

The first two letters/numbers refer to red, the next two refer to green, and the last two refer to blue. The color values are defined in values between 00 and FF (instead of from 0 to 255 in RGB). Numbers are used when the value is 1-9. Letters are used when the value is higher than 9.

Why do we need binary and hexadecimal? ›

Binary and hexadecimal representation in computer systems is very important for computing. Values are stored and processed by a computer in binary representation which is a base 2 representation, a decimal representation which is a base 10 representation and hexadecimal representation which is a base 16 representation.

Is hexadecimal human readable? ›

Another common number system used in Computer Science is base 16, otherwise known as hexadecimal, or hex for short. Why do we use hex? Well, it's a multiple of 2, so it is relatively easy to convert between binary and hex, and hex values are more human readable and understandable than the longer binary values.

Why does memory use hexadecimal? ›

Computers convert binary data into the hexadecimal (hex) number system because it is much less complex than converting data into decimal numbers, and it is much easier for human beings to read hex numbers than to read binary numbers.

Top Articles
Latest Posts
Article information

Author: Annamae Dooley

Last Updated:

Views: 6495

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.