Binary Number System
Professor Dr. Hasinur Rahaman Khan
Institute of Statistical Research and Training (ISRT)
University of Dhaka
July 12, 2024
Professor Dr. Hasinur Rahaman Khan c 2024 1
Number Systems
Popular number systems in connection with digital computers are:
I Decimal
I Binary
I Octal
I Hexadecimal
Professor Dr. Hasinur Rahaman Khan c 2024 2
Decimal System
I Most commonly used number system in real life.
I Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (total 10 digits).
I Base: 10 (since total number of digits is 10).
Professor Dr. Hasinur Rahaman Khan c 2024 3
Binary System
I Used by digital computers for internal operations.
I Digits: 0 and 1 (total 2 bits, a bit is a short of binary digit).
I Base: 2 (since total number of digits is 2).
Professor Dr. Hasinur Rahaman Khan c 2024 4
Octal System
I Not commonly used.
I Digits: 0, 1, 2, 3, 4, 5, 6, 7 (total 8 digits).
I Base: 8 (since the total number of digits is 8).
Professor Dr. Hasinur Rahaman Khan c 2024 5
Hexadecimal System
I Popular among computer scientists, engineers, and
information technologists.
I Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F (total 16
digits).
I Base: 16 (since the total number of digits is 16).
Professor Dr. Hasinur Rahaman Khan c 2024 6
Decimal System
A positive integer, represented as a string of decimal digits, may be
expressed as a sum of powers of 10.
Example
8253 = 8 × 103 + 2 × 102 + 5 × 101 + 3 × 100 = 8000 + 200 + 50 + 3
Professor Dr. Hasinur Rahaman Khan c 2024 7
Decimal System (contd.)
Any fractional value, represented by a string of decimal digits
together with an embedded decimal point, may also be expressed
by negative powers of 10.
Example
654.526 = 6×102 +5×101 +4×100 +5×10−1 +2×10−2 +6×10−3 =
600 + 50 + 4 + 0.5 + 0.02 + 0.006
Professor Dr. Hasinur Rahaman Khan c 2024 8
Binary System
A binary number is a sequence of bits. The place values in the
binary system are the powers of the base 2.
Example
Decimal Counting Binary Counting
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10 1010
Professor Dr. Hasinur Rahaman Khan c 2024 9
Binary to Decimal Conversion
Binary number can be expressed as the sum of the product of each
of its digit and the digits place value.
Example
1101012 = 1 × 25 + 1 × 24 + 0 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 5310
Professor Dr. Hasinur Rahaman Khan c 2024 10
Decimal to Binary Conversion
To convert a decimal number to binary, convert its integral part
and fractional part separately.
Example
Convert 109.78125 to binary.
Professor Dr. Hasinur Rahaman Khan c 2024 11
Decimal to Binary Conversion (contd.)
To convert the integral part 109 to binary, divide the number and
each successive quotient by 2, noting the remainders:
Example
Divisions Remainders
109 2 1
54 2 0
27 2 1
13 2 1
6 2 0
3 2 1
1 2 1
0 1
Professor Dr. Hasinur Rahaman Khan c 2024 12
Decimal to Binary Conversion (contd.)
To convert the fractional part 0.78125 to binary, multiply the
fractional part and each successive product by 2, noting the
integral part of the product:
Example
Multiplications Integral parts
0.78125 2 1
0.5625 2 1
0.125 2 0
0.25 2 0
0.5 2 1
Professor Dr. Hasinur Rahaman Khan c 2024 13
Binary Arithmetic
Binary addition is performed in the same manner as decimal
addition.
Example
Addition Result
0+0 0
0+1 1
1+0 1
1+1 0 with carry 1
Professor Dr. Hasinur Rahaman Khan c 2024 14
Binary Addition Example
Example
Add the binary numbers 101 and 10.
1012 + 102 = 1112 (binary) 510 + 210 = 710 (decimal)
Professor Dr. Hasinur Rahaman Khan c 2024 15
Binary Subtraction
Binary subtraction can be performed by borrowing just as in
decimal subtraction.
Example
Subtraction Result
0-0 0
1-0 1
1-1 0
0-1 1 with borrow 1
Professor Dr. Hasinur Rahaman Khan c 2024 16
Binary Subtraction Example
Example
Subtract 101 from 1101.
11012 − 1012 = 10002 (binary) 1310 − 510 = 810 (decimal)
Professor Dr. Hasinur Rahaman Khan c 2024 17
Binary Multiplication
Binary multiplication is similar to decimal multiplication but
simpler because it involves only 0s and 1s.
Example
Multiply 101 by 11.
1012 × 112 = 11112 (binary) 510 × 310 = 1510 (decimal)
Professor Dr. Hasinur Rahaman Khan c 2024 18
Exercise (A)
I Convert the following binary numbers to decimal:
I 110011
I 10101
I 1011.101
I 101.1101
I 11.0011
Professor Dr. Hasinur Rahaman Khan c 2024 19
Exercise (B)
I Convert the following decimal numbers to binary:
I 1.325
I 625.625
I 235.07
I 13.6875
I 4325
I 10043
Professor Dr. Hasinur Rahaman Khan c 2024 20
Exercise (C)
I Add the binary numbers:
I 100111 and 11011
I 1011 and 101
I 1010110 and 1011010
I 10111 and 1011
I Subtract:
I 0110111 from 1101110
I 01010 from 10000
I 011011 from 110111
Professor Dr. Hasinur Rahaman Khan c 2024 21