FAC1002 - Binary Number System
FAC1002 - Binary Number System
FAC1002 - Binary Number System
INTRODUCTION
Set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, Base, b = 10
Representation, {10n}
Notation : 72710 or 727
MULTIPLICATION 4.166
Example 5 0.19
x 0.79154
DIVISION
Example 6 41.66 416.6 4166
... 0.064379539
647.1 6471 64710
BINARY SYSTEM
In magnetic storage devices (Hard Rigid Disk, Floppy, Zip, Tape, etc.) magnetized
: a magnetized area stands for 1, and the absence of magnetization means 0.
Flip-flops-electronic devices that can only carry two distinct voltages at their
outputs and that can be switched from one state to the other state by an impulse-
can also be used to represent binary numbers;
• An individual unit of information is usually
represented in the computer by a sequence of these
binary digits (called bits ) .
bits (Binary Digits)
The smallest unit of data a computer can process
Unit of byte
prefix-B. Examples (kB = 103 Bytes,
MB for 106 Bytes, GB for 109 Bytes,
TB for 1012 Bytes, PB 1015 Bytes)
CODING SCHEMES
INTRODUCTION
Set = {0, 1}, Base, b = 2
Representation, {2n} i.e. { …, 2-2, 2-1, 20, 21, 22,… }
Notation : 1001012
Example
(Converting an integer, NI = 737 to binary equivalent)
2 737
2 368 1
2 184 0
2 0
92
2 0
46
0
2 23
1
2 11
1
2 5 1
2 2 0 Remainders (Direction of reading)
2 1 1
0
Example
(Converting a floating-point, NF = 0.84375 to binary equivalent)
0.84375
2 Keep 1 and just multiply
1 .6875 0.6875 x 2 = 1.375
2 Keep 1 and just multiply
1 .375 0.375 x 2 = 0. 75
2 Keep 0 and just multiply
0 .75 0. 75 x 2 =1.5
2 Keep 1 and just multiply
1 .5 0. 5 x 2 =1.0
2 Cannot multiply anymore because
1 .0 what left is just zero so you can stop now.
Integral Parts
(Direction of Therefore, NF = 0.8437510 is equivalent to
reading) NF = 0.110112
Example
02 12 02 12
+02 +02 + 12 + 12
02 12 12 1 02
17
Normal procedure for addition and subtraction in binary numbers
1010112 110112
+ 10002 + 10102
1100112 1001012
1010112 1
1000 2 1010002
- 10002 - 1002 - 10112
1000112 1002 111012
From the right hand side
Step 1: 0-0 = 0
Step 2: 0-0 = 0
Step 3: Borrow to make 10-1=1
Your final answer 1002
Multiplication and Division in binary numbers
Example:
BASE
1 0 1 2
x 1 1 2
1 0 1 2
1 0 1 2
1 1 1 1 2
Example:
BASE
1 1 1 2
x 1 1 2
1 1 1 2
+ 1 1 1 2
1 0 1 0 1 2
1+1=2 ( in decimal)
but in binary its 102
That’s why 1 is
carry forward to the
other side then...
1+1+1=3 ( in
decimal)
but in binary its 112
That’s why 1 is
carry forward to the
other side.
Multiplication and Division in binary numbers
Example:
11112 ÷ 1012 = 112
1 1
101 1 1 1 1
-1 0 1
1 0 1
-1 0 1
- - -
Example:
1 1. 0 1 0 1
11 1 0 0 11 1 0 0. 0 0 0 0
- 1 1 - 1 1
1 0
1
0
1 0 0
1 1
1 0
- 0
1 0 0
- 1 1
1
Binary Mathematics
• The fact that data is represented in binary allows a computer
to convert numbers, as data elements, by the mathematical
operations of programmed addition, subtraction,
multiplication and division.
23
Binary Mathematics
• For that reason the mathematics of binary are based on
increments and decrements.
24
Binary Mathematics
• *** Note ***
Decrements in binary mathematics are achieved, not
by simple subtraction, but by the addition of a
negative number!
25
Several schemes representing signed integer in a computer.
Signed number representations are required to encode
negative numbers in binary number systems.
1. sign-magnitude
2. 1’s complement
3. 2’s complement
The sign and magnitude (absolute value) of the integer are represented
separately
A negative integer, for example is represented by “1” in the leftmost bit
and the absolute value in the remaining bits.
27 26 25 24 23 22 21 20
30: 0 0 0 1 1 1 1 0
-30: 1 0 0 1 1 1 1 0
-30 : 1 1 1 0 0 0 0 1
Prob: -0 and +0 are represented differently even though they are the
same algebraically
Addition in 1’s complement
Rule: Carry over of leftmost digit during addition is added back to the bit
string
23 22 21 20
+1: 0 0 0 1
1
-1 : 1 1 1 02
+5: 0 1 0 12 +
10 0 1 12 0 0 1 12
12 +
0 1 0 02 +4
27 26 25 2 4 23 22 21 20
i. 30 : 0 0 0 1 1 1 1 0
ii. 1 1 1 0 0 0 0 1
iii. 1+
-30: 1 1 1 0 0 0 1 02
Addition in 2’s Complement
Adding two 2’s complement numbers involve adding the bit strings as an unsigned
number and ignoring the carry out of the leftmost bit if there is one
Example:
92= 0 1 0 1 1 1 0 0
-45 = ??
Firstly 45 = 00101101
Complemented = 11010010
Add 1 = 11010011
Therefore -45 = 11010011
92 : 0 1 0 1 1 1 0 0
-45 : + 1 1 0 1 0 0 1 1 Drop the leftmost
1 001011112 carry bit: =001011112