Binary, hexadecimal numbers

12.1.1.1 convert binary numbers to hexadecimal  

12.1.1.2 explain the advantages of using hexadecimal numbers in computer systems 

Binary, hexadecimal numbers

The binary number system

If in the decimal system, the numbers can be represented by ten digits 0-9, for example, 250; 897; 110, etc,
The binary system uses two digits: 0 and 1, for example, 100, 1101, 110, etc.

To better understand the simplicity of the binary number system, it is best to examine how our familiar decimal number system works. Columns, right-to-left, represent units, tens and hundreds, etc.
We mentally multiply the values with their column value and add the total.

103=1000 102=100 101=10 100=1  
3 6 0 9  
3000 +600 +0 +9 =360910

The principle is exactly the same in the binary number system. As we move from right to left, each digit is worth twice as much as the previous one, instead of ten times as much.

27=128 26=64 25=32 24=16 23=8 22=4 21=1 20=1  
1 0 0 1 0 1 0 1 =100101012
128     16   4   1 =14910

The minimum and maximum values that can be represented using unsigned binary for n bits are 0 and 2n-1 respectively.

Converting from decimal to binary

To convert a decimal number to binary, first write headings from right to left of 1, 2, 4, 8 ... 128. (If the number given is greater than 255, continue writing headings).

Any decimal number can be represented as the sum of powers of two. The power of two that we use is denoted 1, if not, we denote 0.

For example, the number 105 consists of powers of two such as 64 + 32 + 8 + 1 (look at the table below)

128 64 32 16 8 4 2 1  
0 1 1 0 1 0 0 1 10510=11010012

The hexadecimal number system

The hexadecimal system, often referred to as simply 'hex', uses a base of 16 as follows: 

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

Converting from binary to hexadecimal and vice versa

To convert a binary number to hexadecimal, split the binary number into groups of 4 binary digits (nibble) from right to left.

For example, convert binary number 10 1101 0011 1010 to hex. 

Binary 0010 1101 0011 1010  
Hex 2 D 3 A 10 1101 0011 10102=2D3A16

Nibble - four bits or half an octet

The advantages of using hexadecimal numbers in computer systems

The main reason that hexadecimal numbers are used is because it is much easier to express binary number representations in hex than it is in any other base number system. 

Although computers do not use hex, it is easier for humans to remember and express binary numbers in hex.

A two-digit hex number can represent a byte.

To determine memory location. Hexadecimal can characterize every byte as two hexadecimal digits only compared to eight digits when using binary.

To define colors on web pages and in programming languages (eg. Python). Each primary color – red, green, and blue is characterized by two hexadecimal digits.  The format being used is #RRGGBB.  RR stands for red, GG stands for green and BB stands for blue.

To represent MAC addresses. Media Access Control addresses consist of 12-digit hexadecimal numbers. For example, 00:A0:C9:14:C8:29 

To display error messages. Hexadecimal are used to define the memory location of the error.  This is useful for programmers in finding and fixing errors.


Questions:

1. How many digits are used in decimal, binary, and hexadecimal?

2. What is the difference between decimal, binary, and hexadecimal?

3. Imagine people with 10 eyes, 10 legs, 10 hands, and 100000 teeth. How is this possible?

4. Explain what nibble is.


Exercises:

Ex. 1 Matching hex and nibble. 

Ex. 2 Fill the gaps and write down your decision to copybook. 

Ex. 3 Distribute numbers according to number systems with minimal base. 

Ex. 4 Decode the hidden message


Exam questions:

Question. Explain why hexadecimal numbers are often used to represent binary numbers.(Marks: 2)
  • Answer.

    Hex numbers are shorter/more memorable than equivalent binary numbers...(1)

    ... and can easily be converted to and from binary...(1)

    ... as each hex digit corresponds to 4 binary digits (1)

 

Категория: Representing numbers | Добавил: bzfar77 (01.02.2021)
Просмотров: 5342 | Теги: Binary, Dec, hexadecimal, bin, Hex, denary, represent number | Рейтинг: 5.0/3
Всего комментариев: 0
avatar