0% found this document useful (0 votes)
12 views19 pages

12-CN-Chap6-Conversion Binary To Decimal, Hexadecimal

Uploaded by

Razan Hoteit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views19 pages

12-CN-Chap6-Conversion Binary To Decimal, Hexadecimal

Uploaded by

Razan Hoteit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Computer Networks

Chapter 6
Binary to Decimal, Hexadecimal Conversion

By: Hamssa Hasrouny


6-1
Positional Notation
‣ A positional or place-value notation is a numeral system in which each position is related to the next by a
constant multiplier, called the base or radix of that numeral system.

‣ The value of each digit position is the value of its digit, multiplied by a power of the base.
The power is determined by the digit's position.

‣ The value of a positional number is the total of the values of its positions.

6-2
Binary System
‣ A binary number is a number expressed in the base-2 numeral system
• Uses only two symbols: 0 and 1
• A single binary digit is called a bit.

6-3
6-4
6-5
6-6
6-7
(Base 10) (Base 2) (Base 16)

6-8
6-9
Examples:
DIGIT × BASE #POSITION

Decimal Number:

4567
= 4000 + 500 + 60 + 7
= (4 × 1000) + (5 × 100) + (6 × 10) + (7 × 1)
= (4 × 10 ) + (5 × 10 ) + (6 × 10 ) + (7 ×10 )
3 2 1 0

Binary to decimal:

(11101)2 =
(1×2 )+(1×2 )+(1×2 )+(0× 2 )+(1×2 )
4 3 2 1 0

= (1×16)+(1×8)+(1×4)+(0×2)+(1×1)= 16+8+4+0+1= 29d


Hexadecimal to decimal

(1FA)16=
(1×16 )+(F×16 )+(A×16 )=(1×16 )+(15×16 )+(10×16 )=506d
2 1 0 2 1 0

6-10
Decimal to Binary
4410 to base 2

(44)10 = (101100)2

Decimal to Hexadecimal
3110 ? hexadecimal
3110 = 1F16

31/16 = 1 remainder = 15

1/16 = 0 remainder = 1

6-11
Binary to Hexadecimal
base 16 =24
Each bit in hexadecimal is expanded over 4bits in binary and vice-versa
Base16: 0, 1, … 9, A, B, C, D, E, F

Example :
F16 = 1111
Convert 1111012 to Hexadecimal

1111012 = 0011 11012 = = (1x21 + 1x20) (1x23 +1x22 +1x20)= 3 13


1111012 → 3D16

Hexadecimal to Binary
convert 3D16 to Binary

316 =00112
D16 =11012
3D16 = 0011 11012
6-12
Binary and IPv4 Addresses

• Binary numbering system consists of 1s and 0s, called bits


• Decimal numbering system consists of digits 0 through 9
• Hosts, servers, and network equipment using binary addressing to identify each other.
• Each address is made up of a string of 32 bits, divided into four sections called octets.
• Each octet contains 8 bits (or 1 byte) separated by a dot.
• For ease of use by people, this dotted notation is converted to dotted decimal.

6-13
6-14
6-15
The binary positional notation system operates as shown in the tables below.
Radix 2 2 2 2 2 2 2 2

Position in Number 7 6 5 4 3 2 1 0

Calculate (27) (26) (25) (24) (23) (22) (21) (20)

Position Value 128 64 32 16 8 4 2 1

Positional Value 128 64 32 16 8 4 2 1

Binary Number (11000000) 1 1 0 0 0 0 0 0

Calculate 1x128 1x64 0x32 0x16 0x8 0x4 0x2 0x1

Add Them Up… 128 + 64 +0 +0 +0 +0 +0 +0

Result 192

6-16
Binary Number System
Convert Binary to Decimal
Convert 11000000.10101000.00001011.00001010 to decimal.
Positional Value 128 64 32 16 8 4 2 1

Binary Number (11000000) 1 1 0 0 0 0 0 0

Calculate 1x128 1x64 0x32 0x16 0x8 0x4 0x2 0x1

Add Them Up… 128 + 64 +0 +0 +0 +0 +0 +0 192


Binary Number (10101000) 1 0 1 0 1 0 0 0

Calculate 1x128 0x64 1x32 0x16 1x8 0x4 0x2 0x1

Add Them Up… 128 +0 + 32 +0 +8 +0 +0 +0 168


Binary Number (00001011) 0 0 0 0 1 0 1 1
192.168.11.10
Calculate 0x128 0x64 0x32 0x16 1x8 0x4 1x2 1x1

Add Them Up… 0 +0 +0 +0 +8 +0 +2 +1 11


Binary Number (00001010) 0 0 0 0 1 0 1 0

Calculate 0x128 0x64 0x32 0x16 1x8 0x4 1x2 0x1

Add Them Up… 0 +0 +0 +0 +8 +0 +2 +0 10

6-17
Binary Number System
Decimal to Binary Conversion Example
• Convert decimal 168 to binary
Is 168 > 128?
- Yes, enter 1 in 128 position and subtract 128 (168-128=40)
Is 40 > 64?
- No, enter 0 in 64 position and move on
Is 40 > 32?
- Yes, enter 1 in 32 position and subtract 32 (40-32=8)
Is 8 > 16?
- No, enter 0 in 16 position and move on
Is 8 > 8?
- Equal. Enter 1 in 8 position and subtract 8 (8-8=0)
No values left. Enter 0 in remaining binary positions

128 64 32 16 8 4 2 1
1 0 1 0 1 0 0 0
Decimal 168 is written as 10101000 in binary
6-18
Binary Number System
IPv4 Addresses
• Routers and computers only understand binary, while humans work in decimal.

End of Chapter 6 6-19

You might also like