0% found this document useful (0 votes)
3 views31 pages

Tutorial 02 - Arithmetic Operations

The document provides an overview of arithmetic operations in binary, including addition, subtraction, multiplication, and division. It explains number representation methods such as unsigned, signed, and floating-point representations, along with techniques like one's and two's complement for handling negative numbers. Additionally, it covers converting binary fractions to decimal and vice versa, as well as the process of representing decimal numbers in binary floating-point format.

Uploaded by

icttrincomalee
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)
3 views31 pages

Tutorial 02 - Arithmetic Operations

The document provides an overview of arithmetic operations in binary, including addition, subtraction, multiplication, and division. It explains number representation methods such as unsigned, signed, and floating-point representations, along with techniques like one's and two's complement for handling negative numbers. Additionally, it covers converting binary fractions to decimal and vice versa, as well as the process of representing decimal numbers in binary floating-point format.

Uploaded by

icttrincomalee
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

Arithmetic Operations

SCS 1205
Computer Systems
Binary Addition
Addition Result Carry
Carry
0+0 = 0 0
0+1 = 1 0
1+0 = 1 0
1+1 = 0 1

Addition Result Carry

1+1+1 1 1
2
Binary Subtraction
Subtraction Result

0-0 = 0

0-1 = 1 * with borrow

1-0 = 1

1-1 = 0

3
Binary Multiplication

Multiplication Result

0*0 = 0
0*1 = 0
1*0 = 0
1*1 = 1

4
Decide whether it is 0 or 1
Binary Division ●

Quotient

Divisor

Remainder

5
Number representation

Number
Representation

Unsigned Signed Floating-point


representation representation representation

6
Unsigned Binary Numbers
Magnitude is the bits in the
pattern which store the size
of the number

● All the bits are used for representing magnitude

Smallest 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

Largest
1 1 1 1 1 1 1 1
128 64 32 16 8 4 2 1
7
Signed Binary Numbers
• Left most number is the sign bit.
0 -> positive
1 -> negative

Sign bit Magnitude


(bits in the pattern store the size of the number)
8
Signed Binary Numbers
• The largest magnitude is 127, which is approximately half of
what is for unsigned binary numbers.

0 1 1 1 1 1 1 1
64 32 16 8 4 2 1

9
Problems in signed representation
• +0 and -0
• Need to consider both sign and magnitude in arithmetic

7 – 4 = ?? 00000111
= 7+(-4) + 10000100
=3 10001011 = -11

10
One’s Complement
A method which we can use to represent negative binary numbers in a
signed binary number system.
● One’s complement of 1 is 0
● One’s complement of 0 is 1

10110101

01001010 One’s Complement

11
One’s Complement
1111111 Carry
7 – 4 = ??
00000111 7
= 7+(-4)
+ 11111011 one’s complement of 4
4 100000010
00000100
+ 1
11111011 00000011 = 3
one’s complement value of 4

❖ In one’s complement if there is a carry value generated after the sign bit. it will be added
to result.
12
One’s Complement
115 – 27 = ?? 11 Carry

01110011 115
= 115+(-27) + 11100100 one’s complement of 27
00011011 27 101010111
+ 1
11100100
01011000 = 88
one’s complement value of 27

13
Two’s Complement
● 2’s complement of a binary number is 1 added to the 1’s complement
of the binary number.

00000111 ← Binary Number


11111000 ← One’s complement
+ 1
11111001 ← Two’s complement

14
Two’s Complement
7 – 4 = ??
= 7+(-4)

Binary → 00000100 11111 Carry

1’s complement → 11111011 00000111


+ 1 + 11111100
2’s complement → 11111100 100000011 =3

15
Two’s Complement
115 – 27 = ??
= 115+(-27)
11 111 Carry
00011011
01110011
1’s complement → 11100100
+ 11100101
+1
101011000 = 88
2’s complement → 11100101

16
Fractions in binary to decimal

1 0 1 . 0 1 1
22 21 20 2-1 2-2 2-3

4 0 1 0 1/4 1/8

4+0+1+¼+⅛=5⅜
101.0112 = 5.37510
17
Fractions : binary to decimal
1 1 1 . 0 1

4 2 1 0 ¼

18
Fractions : decimal to binary
1. Multiply the number by the base (=2)
2. Take the integer on the left (0 or 1) as the coefficient.
3. Take the resultant fraction and repeat the division until resultant is zero

Eg : 0.75010 0 750 * 2
1 500 * 2
1 000
0.75010 = 0.112

19
Non-integer Representation (Float point)

Mantissa/Significand Exponent

Binary Point Base

20
Scientific Notation

21
Binary floating point representation
● 32-bit floating point representation
● Also called as single precision.

Sign of
significand
8 bits 23 bits

Biased exponent Significand / Mantissa

22
Binary floating point representation

Represent 175.625 in 32-bit binary floating point number

23
Eg : Represent 175.625 in 32-bit binary floating point number

STEP 01 : Convert the given decimal number to binary

2 175 0 625 * 2
2 87 - 1 1 250 * 2
2 43 - 1 0 500 * 2
2 21 - 1 1 000
2 10 - 1
2 5 -0
175.62510 = 10101111.1012
2 2 -1
1 -0
24
Eg : Represent 175.625 in 32-bit binary floating point number

STEP 02 : Represent binary number in the scientific notation

Binary number → 10101111.1012

1 0101111.101 Exponent

10101111.101 = 1.0101111101 x 27
Mantissa

25
Eg : Represent 175.625 in 32-bit binary floating point number

STEP 03 : Represent scientific notation in 32-bit binary floating


number
i) Assign the sign bit
Exponent

1.0101111101 x 27
Mantissa

0; since 175.625 is a positive number


26
Eg : Represent 175.625 in 32-bit binary floating point number
STEP 03 : Represent scientific notation in 32-bit binary floating
number
ii) Find the binary representation of biased exponent
1.0101111101 x 27
(For a 8 bit exponent → bias = 127)

Biased exponent = bias + exponent


= 127 + 7
= 134
Binary representation of 13410 = 100001102

0 10000110
27
Eg : Represent 175.625 in 32-bit binary floating point number
STEP 03 : Represent scientific notation in 32-bit binary floating
number
iii) Assign the mantissa and fill the rest with zeros

1.0101111101 x 27
Mantissa

0 10000110 01011111010000000000000

28
Binary floating point representation
Eg : Represent the following 32-bit binary floating point number in
scientific notation.

0 01100111 00101000110001000000000

29
0 01100111 00101000110001000000000

Sign bit = 0;
positive
Significand :
011001112 = 10310
= 1 + (0*2-1) + (0*2-2) + (1*2-3) + (0*2-4) + (1*2-5)+......
Bias adjustment = 103 - 127
= -24 = 1 + 0 + 0 + ⅛ + 0 + 1/32 ….
= 1 + 0.1592407
= 1.1592407

Simplify this to get the decimal


1.1592407 x 2-24 scientific notation

Scientific Notation : 6.909613013 x 10-8


30
Thank You!!

31

You might also like