SlideShare a Scribd company logo
Computer Arithmetic 
By 
Roll No. 2,Roll No.10 
Department of CS & IT 
University of Azad Jammu & Kashmir, MZD 
To 
Prof. Dr. Wajid Aziz Loun 
Chairman, DCS & IT/Prof. of Subject 
Advance Computer Architecture 
University of Azad Jammu & Kashmir, MZD
Presentation Topics 
Part I: Number Representation 
Part II: Addition / Subtraction 
Part III: Multiplication 
Part IV: Division
Arithmetic & Logic Unit 
• Does the calculations 
• Handles integers 
• May handle floating point (real) numbers
Integer Representation 
• In binary number system, an arbitrary number can be represented with 
– Zero and one 
– The minus sign 
– And period, or radix point 
– e.g. 
• For computer storage and processing 
– Only have 0 & 1 to represent everything 
– Positive numbers stored in binary. (For example 41=00101001) 
– No minus sign 
– No period 
• In general, for n-bit sequence of binary digits an-1 an-2 … a1, ao interpreted 
as unsigned integer A will have value 
å- 
= 
= 
1 
0 
2 
n 
i 
i 
A i a
What’s ALU? 
1. ALU stands for: Arithmetic Logic Unit 
2. ALU is a digital circuit that performs 
Arithmetic (Add, Sub, . . .) and Logical (AND, 
OR, NOT) operations. 
3. John Von Neumann proposed the ALU in 
1945 when he was working on EDVAC. 
Computer Arithmetic, Number 
Representation
Number Systems 
and Binary Arithmetic
Introduction to Numbering Systems 
• We are all familiar with the decimal number 
system (Base 10). Some other number 
systems that we will work with are: 
– Binary ® Base 2 
– Octal ® Base 8 
– Hexadecimal ® Base 16
Characteristics of Numbering Systems 
1) The digits are consecutive. 
2) The number of digits is equal to the size of the 
base. 
3) Zero is always the first digit. 
4) When 1 is added to the largest digit, a sum of zero 
and a carry of one results. 
5) Numeric values determined by the have implicit 
positional values of the digits.
Significant Digits 
Binary: 11101101 
Most significant digit Least significant digit 
Hexadecimal: 1D63A7A 
Most significant digit Least significant digit
Binary Number System 
• Also called the “Base 2 system” 
• The binary number system is used to model the 
series of electrical signals computers use to 
represent information 
• 0 represents the no voltage or an off state 
• 1 represents the presence of voltage or an 
on state
Binary Numbering Scale 
Base 2 
Number 
Base 10 
Equivalent Power Positional 
Value 
000 0 20 1 
001 1 21 2 
010 2 22 4 
011 3 23 8 
100 4 24 16 
101 5 25 32 
110 6 26 64 
111 7 27 128
Binary Addition 
4 Possible Binary Addition Combinations: 
(1) 0 (2) 0 
+0 +1 
00 01 
Carry Sum 
(3) 1 (4) 1 
+0 +1 
01 10 
Note that leading 
zeroes are frequently 
dropped.
Decimal to Binary Conversion 
• The easiest way to convert a decimal number to its 
binary equivalent is to use the Division Algorithm 
• This method repeatedly divides a decimal number by 
2 and records the quotient and remainder 
– The remainder digits (a sequence of zeros and ones) form 
the binary equivalent in least significant to most 
significant digit sequence
Division Algorithm 
Convert 67 to its binary equivalent: 
6710 = x2 
Step 1: 67 / 2 = 33 R 1 Divide 67 by 2. Record quotient in next row 
Step 2: 33 / 2 = 16 R 1 Again divide by 2; record quotient in next row 
Step 3: 16 / 2 = 8 R 0 Repeat again 
Step 4: 8 / 2 = 4 R 0 Repeat again 
Step 5: 4 / 2 = 2 R 0 Repeat again 
Step 6: 2 / 2 = 1 R 0 Repeat again 
Step 7: 1 / 2 = 0 R 1 STOP when quotient equals 0 
1 0 0 0 0 1 12
Binary to Decimal Conversion 
• The easiest method for converting a binary 
number to its decimal equivalent is to use the 
Multiplication Algorithm 
• Multiply the binary digits by increasing powers 
of two, starting from the right 
• Then, to find the decimal number equivalent, 
sum those products
Multiplication Algorithm 
Convert (10101101)2 to its decimal equivalent: 
Binary 1 0 1 0 1 1 0 1 
Positional Values x x x x x x x x 
27 26 25 24 23 22 21 20 
Products 128 + 32 + 8 + 4 + 1 
17310
Octal Number System 
• Also known as the Base 8 System 
• Uses digits 0 - 7 
• Readily converts to binary 
• Groups of three (binary) digits can be used to 
represent each octal digit 
• Also uses multiplication and division 
algorithms for conversion to and from base 10
Decimal to Octal Conversion 
Convert 42710 to its octal equivalent: 
427 / 8 = 53 R3 Divide by 8; R is LSD 
53 / 8 = 6 R5 Divide Q by 8; R is next digit 
6 / 8 = 0 R6 Repeat until Q = 0 
6538
Octal to Decimal Conversion 
Convert 6538 to its decimal equivalent: 
6 5 3 
x x 2 81 80 
x8 
384 + 40 + 3 
42710 
Octal Digits 
Positional Values 
Products
Octal to Binary Conversion 
Each octal number converts to 3 binary digits 
To convert 6538 to binary, just 
substitute code: 
6 5 3 
110 101 011
Hexadecimal Number System 
• Base 16 system 
• Uses digits 0-9 & 
letters A,B,C,D,E,F 
• Groups of four bits 
represent each 
base 16 digit
Decimal to Hexadecimal Conversion 
Convert 83010 to its hexadecimal equivalent: 
830 / 16 = 51 R14 
51 / 16 = 3 R3 
3 / 16 = 0 R3 
33E16 
= E in Hex
Hexadecimal to Decimal Conversion 
Convert 3B4F16 to its decimal equivalent: 
Hex Digits 
3 B 4 Fx 
x x 
163 162 161 160 
12288 +2816 + 64 +15 
15,18310 
Positional Values 
Products 
x
Binary to Hexadecimal Conversion 
• The easiest method for converting binary to 
hexadecimal is to use a substitution code 
• Each hex number converts to 4 binary digits
Substitution Code 
Convert 0101011010101110011010102 to hex using the 
4-bit substitution code : 
5 6 A E 6 A 
0101 0110 1010 1110 0110 1010 
56AE6A16
Substitution Code 
Substitution code can also be used to convert binary to 
octal by using 3-bit groupings: 
2 5 5 2 7 1 5 2 
010 101 101 010 111 001 101 010 
255271528
Complementary Arithmetic 
• 1’s complement 
– Switch all 0’s to 1’s and 1’s to 0’s 
Binary # 10110011 
1’s complement 01001100
Complementary Arithmetic 
• 2’s complement 
– Step 1: Find 1’s complement of the number 
Binary # 11000110 
1’s complement 00111001 
– Step 2: Add 1 to the 1’s complement 
00111001 
+ 00000001 
00111010
Signed Magnitude Numbers 
110010.. …00101110010101 
Sign bit 
0 = positive 
1 = negative 
31 bits for magnitude 
This is your basic 
Integer format
Sign-Magnitude 
• Left most bit is sign bit 
– 0 means positive 
– 1 means negative 
• +18 = 00010010 
• -18 = 10010010 
• The general case can be expressed as follows 
• Problems 
ü 
= 
å 
a if a 
2 0 
- 
– Need to consider both sign and magnitude in arithmetic 
– Two representations of zero (+0 and -0) 
+010 = 00000000 
-010 = 10000000 
ï ïþ 
ï ïý 
ï ïî 
ï ïí ì 
- = 
= 
å 
= 
- 
- 
= 
- 
2 
0 
1 
2 
0 
1 
2 1 
n 
i 
i n 
i 
n 
i 
i n 
i 
a if a 
A
Negation (Sign Magnitude Representation) 
• In sign magnitude representation, the sign bit 
is inverted for forming negative of an integer. 
– For 8 bit sign magnitude representation 
+1810 = 00010010 
-1810 = 10010010 
– For 16 bit sign magnitude representation 
+1810 =0000000000010010 
-1810 =1000000000010010
Two’s Compliment 
• The general expression for two’s complement 
representation is 
A n a a 
• +3 = 00000011 
• +2 = 00000010 
• +1 = 00000001 
• +0 = 00000000 
• -1 = 11111111 
• -2 = 11111110 
• -3 = 11111101 
å- 
2 1 2 
= 
= - - + 
- 
2 
0 
1 
n 
i 
i 
i 
n
Negation (Twos Complement Representation) 
• In twos complement representation, negation of 
an integer can be formed with following rules. 
– Take the Boolean complement of each bir of integer 
(including sign bit). 
– Add 1 treating the result as an unsigned integer. 
• The two step process is referred to as twos 
complement operation. 
+18=00010010 
Bitwise Complement =11101101 
+ 1 
11101110= -18
Negation Special Case 1 
• The negation of 0 is 0. 
0 = 00000000 
Bitwise not 11111111 
Add 1 to LSB +1 
Result 100000000=0 
• Overflow is ignored, so: 
• The result of negation of 0 is 0.
Negation Special Case 2 
• The negation of the bit pattern followed by n-1 
zeros results back the same number. 
-128 = 10000000 
Bitwise not 01111111 
Add 1 to LSB +1 
Result 10000000=-128 
• Monitor MSB (sign bit) 
• It should change during negation 
• Such anomaly is unavoidable.
Value Box for Conversion between Twos Complement Binary 
and Decimal 
-128 64 32 16 8 4 2 1 
An Eight Position Twos Complement Value Box 
-128 64 32 16 8 4 2 1 
1 0 0 0 0 0 1 1 
-128 +2 +1 =-125 
Converting Binary 10000011 to Decimal 
-128 64 32 16 8 4 2 1 
1 0 0 0 1 0 0 0 
-128 +8 =-120 
Converting Decimal -120 to Binary
Conversion Between Lengths 
• Positive number pack with leading zeros 
+18 = 00010010 
+18 = 00000000 00010010 
• Negative numbers pack with leading ones 
-18 = 10010010 
-18 = 11111111 10010010 
• i.e. pack with MSB (sign bit)
Addition and Subtraction 
• Normal binary addition 
• Monitor sign bit for overflow 
• Take twos compliment of subtrahend and add 
to minuend 
– i.e. a - b = a + (-b) 
• So we only need addition and complement 
circuits
Addition and Subtraction (Examples) 
• Additionn of Numbers in Twos Complement 
(a) (+3) + (+4) 
0011 
+ 0100 
0111 = 7 
(b) (-7) + (+5) 
1001 
+ 0101 
1110 =-2 
(c) (-4) + (-1) 
1100 
+ 1111 
11011 =-5 
(d) (-4) + (+4) 
1100 
+0100 
10000 =0 
(e) (+5) + (+4) 
0101 
+0100 
1001 =Overflow 
(f) (-7) + (-6) 
1001 
+1010 
10011 =Overflow
Addition and Subtraction (Examples) 
• Subtraction of Numbers in Twos Complement 
(a) (+2) – (+7) 
0010 
+ 1001 
1011 = -5 
(b) (+5) - (+2) 
0101 
+ 1110 
1011 =3 
(c) (-5) - (+2) 
1011 
+ 1110 
11001 =-7 
(d) (+5) - (-2) 
0101 
+0010 
0111 =7 
(e) (+7) - (-7) 
0111 
+0111 
1100 =Overflow 
(f) (-6) - (+4) 
1010 
+1100 
10110 =Overflow
Hardware for Addition and Subtraction

More Related Content

What's hot

Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number system
ISMT College
 
Codes r005
Codes  r005Codes  r005
Codes r005
arunachalamr16
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
Mohammad Bashartullah
 
Binary coded decimal r004
Binary coded decimal   r004Binary coded decimal   r004
Binary coded decimal r004
arunachalamr16
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemes
Dr. Anita Goel
 
Digital Electronics and Computer Language
Digital Electronics and Computer Language Digital Electronics and Computer Language
Digital Electronics and Computer Language
Manthan Chavda
 
Code conversion r006
Code conversion r006Code conversion r006
Code conversion r006
arunachalamr16
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmeticgavhays
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
Meenakshi Paul
 
Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes
VandanaPagar1
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
pyingkodi maran
 
2.1 data represent on cpu
2.1 data represent on cpu2.1 data represent on cpu
2.1 data represent on cpuWan Afirah
 
Number system
Number systemNumber system
Number system
rameshthombre1
 
Number systems
Number systemsNumber systems
Number systems
thechamp3
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
arunachalamr16
 
Representation of Signed Numbers - R.D.Sivakumar
Representation of Signed Numbers - R.D.SivakumarRepresentation of Signed Numbers - R.D.Sivakumar
Representation of Signed Numbers - R.D.Sivakumar
Sivakumar R D .
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representationgavhays
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Ra'Fat Al-Msie'deen
 

What's hot (20)

Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number system
 
Codes r005
Codes  r005Codes  r005
Codes r005
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
 
Binary coded decimal r004
Binary coded decimal   r004Binary coded decimal   r004
Binary coded decimal r004
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemes
 
Digital Electronics and Computer Language
Digital Electronics and Computer Language Digital Electronics and Computer Language
Digital Electronics and Computer Language
 
Code conversion r006
Code conversion r006Code conversion r006
Code conversion r006
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
 
Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
 
2.1 data represent on cpu
2.1 data represent on cpu2.1 data represent on cpu
2.1 data represent on cpu
 
Number system
Number systemNumber system
Number system
 
Number systems
Number systemsNumber systems
Number systems
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
 
Representation of Signed Numbers - R.D.Sivakumar
Representation of Signed Numbers - R.D.SivakumarRepresentation of Signed Numbers - R.D.Sivakumar
Representation of Signed Numbers - R.D.Sivakumar
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representation
 
09 arithmetic
09 arithmetic09 arithmetic
09 arithmetic
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
 

Viewers also liked

Binary numbers-7-12-2011
Binary numbers-7-12-2011Binary numbers-7-12-2011
Binary numbers-7-12-2011
Januário Esteves
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Piyush Rochwani
 
Biometrics based key generation
Biometrics based key generationBiometrics based key generation
Biometrics based key generation
Piyush Rochwani
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
Sanjay Saluth
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
Chamila Fernando
 
Unit 3
Unit 3Unit 3
Unit 2
Unit 2Unit 2
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
중선 곽
 

Viewers also liked (10)

Binary numbers-7-12-2011
Binary numbers-7-12-2011Binary numbers-7-12-2011
Binary numbers-7-12-2011
 
Cisc(a022& a023)
Cisc(a022& a023)Cisc(a022& a023)
Cisc(a022& a023)
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)
 
Biometrics based key generation
Biometrics based key generationBiometrics based key generation
Biometrics based key generation
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 2
Unit 2Unit 2
Unit 2
 
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
 
06 floating point
06 floating point06 floating point
06 floating point
 

Similar to Alu1

Number_Systems (2).ppt
Number_Systems (2).pptNumber_Systems (2).ppt
Number_Systems (2).ppt
nivedita murugan
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
GnanaDeepikaMeduri
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
amudhak10
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
amudhak10
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
NabeelaNousheen
 
Finite word length effects
Finite word length effectsFinite word length effects
Finite word length effects
PeriyanayagiS
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt
RavikumarR77
 
Course Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdfCourse Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdf
MdJubayerFaisalEmon
 
DLD-Introduction.pptx
DLD-Introduction.pptxDLD-Introduction.pptx
DLD-Introduction.pptx
UzairAhmadWalana
 
Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:
Asif Iqbal
 
digitalelectronics.ppt
digitalelectronics.pptdigitalelectronics.ppt
digitalelectronics.ppt
HarshalVaidya11
 
Lecture 2 ns
Lecture 2 nsLecture 2 ns
Lecture 2 ns
Rabiul Sarker
 
Digital Logic Design.pptx
Digital Logic Design.pptxDigital Logic Design.pptx
Digital Logic Design.pptx
AminaZahid16
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
TamiratDejene1
 
Number system
Number systemNumber system
Number system
Mantra VLSI
 
Module 2_Data representations.pdf
Module 2_Data representations.pdfModule 2_Data representations.pdf
Module 2_Data representations.pdf
Aditya kishore saxena
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
Ravi Kumar
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
Ravi Kumar
 
21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx
GobinathAECEJRF1101
 

Similar to Alu1 (20)

Number_Systems (2).ppt
Number_Systems (2).pptNumber_Systems (2).ppt
Number_Systems (2).ppt
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
 
Finite word length effects
Finite word length effectsFinite word length effects
Finite word length effects
 
Okkkkk
OkkkkkOkkkkk
Okkkkk
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt
 
Course Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdfCourse Name: Digital System Design Number System.pdf
Course Name: Digital System Design Number System.pdf
 
DLD-Introduction.pptx
DLD-Introduction.pptxDLD-Introduction.pptx
DLD-Introduction.pptx
 
Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:
 
digitalelectronics.ppt
digitalelectronics.pptdigitalelectronics.ppt
digitalelectronics.ppt
 
Lecture 2 ns
Lecture 2 nsLecture 2 ns
Lecture 2 ns
 
Digital Logic Design.pptx
Digital Logic Design.pptxDigital Logic Design.pptx
Digital Logic Design.pptx
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
 
Number system
Number systemNumber system
Number system
 
Module 2_Data representations.pdf
Module 2_Data representations.pdfModule 2_Data representations.pdf
Module 2_Data representations.pdf
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx21EC201– Digital Principles and system design.pptx
21EC201– Digital Principles and system design.pptx
 

Recently uploaded

In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 

Recently uploaded (20)

In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 

Alu1

  • 1. Computer Arithmetic By Roll No. 2,Roll No.10 Department of CS & IT University of Azad Jammu & Kashmir, MZD To Prof. Dr. Wajid Aziz Loun Chairman, DCS & IT/Prof. of Subject Advance Computer Architecture University of Azad Jammu & Kashmir, MZD
  • 2. Presentation Topics Part I: Number Representation Part II: Addition / Subtraction Part III: Multiplication Part IV: Division
  • 3. Arithmetic & Logic Unit • Does the calculations • Handles integers • May handle floating point (real) numbers
  • 4. Integer Representation • In binary number system, an arbitrary number can be represented with – Zero and one – The minus sign – And period, or radix point – e.g. • For computer storage and processing – Only have 0 & 1 to represent everything – Positive numbers stored in binary. (For example 41=00101001) – No minus sign – No period • In general, for n-bit sequence of binary digits an-1 an-2 … a1, ao interpreted as unsigned integer A will have value å- = = 1 0 2 n i i A i a
  • 5. What’s ALU? 1. ALU stands for: Arithmetic Logic Unit 2. ALU is a digital circuit that performs Arithmetic (Add, Sub, . . .) and Logical (AND, OR, NOT) operations. 3. John Von Neumann proposed the ALU in 1945 when he was working on EDVAC. Computer Arithmetic, Number Representation
  • 6. Number Systems and Binary Arithmetic
  • 7. Introduction to Numbering Systems • We are all familiar with the decimal number system (Base 10). Some other number systems that we will work with are: – Binary ® Base 2 – Octal ® Base 8 – Hexadecimal ® Base 16
  • 8. Characteristics of Numbering Systems 1) The digits are consecutive. 2) The number of digits is equal to the size of the base. 3) Zero is always the first digit. 4) When 1 is added to the largest digit, a sum of zero and a carry of one results. 5) Numeric values determined by the have implicit positional values of the digits.
  • 9. Significant Digits Binary: 11101101 Most significant digit Least significant digit Hexadecimal: 1D63A7A Most significant digit Least significant digit
  • 10. Binary Number System • Also called the “Base 2 system” • The binary number system is used to model the series of electrical signals computers use to represent information • 0 represents the no voltage or an off state • 1 represents the presence of voltage or an on state
  • 11. Binary Numbering Scale Base 2 Number Base 10 Equivalent Power Positional Value 000 0 20 1 001 1 21 2 010 2 22 4 011 3 23 8 100 4 24 16 101 5 25 32 110 6 26 64 111 7 27 128
  • 12. Binary Addition 4 Possible Binary Addition Combinations: (1) 0 (2) 0 +0 +1 00 01 Carry Sum (3) 1 (4) 1 +0 +1 01 10 Note that leading zeroes are frequently dropped.
  • 13. Decimal to Binary Conversion • The easiest way to convert a decimal number to its binary equivalent is to use the Division Algorithm • This method repeatedly divides a decimal number by 2 and records the quotient and remainder – The remainder digits (a sequence of zeros and ones) form the binary equivalent in least significant to most significant digit sequence
  • 14. Division Algorithm Convert 67 to its binary equivalent: 6710 = x2 Step 1: 67 / 2 = 33 R 1 Divide 67 by 2. Record quotient in next row Step 2: 33 / 2 = 16 R 1 Again divide by 2; record quotient in next row Step 3: 16 / 2 = 8 R 0 Repeat again Step 4: 8 / 2 = 4 R 0 Repeat again Step 5: 4 / 2 = 2 R 0 Repeat again Step 6: 2 / 2 = 1 R 0 Repeat again Step 7: 1 / 2 = 0 R 1 STOP when quotient equals 0 1 0 0 0 0 1 12
  • 15. Binary to Decimal Conversion • The easiest method for converting a binary number to its decimal equivalent is to use the Multiplication Algorithm • Multiply the binary digits by increasing powers of two, starting from the right • Then, to find the decimal number equivalent, sum those products
  • 16. Multiplication Algorithm Convert (10101101)2 to its decimal equivalent: Binary 1 0 1 0 1 1 0 1 Positional Values x x x x x x x x 27 26 25 24 23 22 21 20 Products 128 + 32 + 8 + 4 + 1 17310
  • 17. Octal Number System • Also known as the Base 8 System • Uses digits 0 - 7 • Readily converts to binary • Groups of three (binary) digits can be used to represent each octal digit • Also uses multiplication and division algorithms for conversion to and from base 10
  • 18. Decimal to Octal Conversion Convert 42710 to its octal equivalent: 427 / 8 = 53 R3 Divide by 8; R is LSD 53 / 8 = 6 R5 Divide Q by 8; R is next digit 6 / 8 = 0 R6 Repeat until Q = 0 6538
  • 19. Octal to Decimal Conversion Convert 6538 to its decimal equivalent: 6 5 3 x x 2 81 80 x8 384 + 40 + 3 42710 Octal Digits Positional Values Products
  • 20. Octal to Binary Conversion Each octal number converts to 3 binary digits To convert 6538 to binary, just substitute code: 6 5 3 110 101 011
  • 21. Hexadecimal Number System • Base 16 system • Uses digits 0-9 & letters A,B,C,D,E,F • Groups of four bits represent each base 16 digit
  • 22. Decimal to Hexadecimal Conversion Convert 83010 to its hexadecimal equivalent: 830 / 16 = 51 R14 51 / 16 = 3 R3 3 / 16 = 0 R3 33E16 = E in Hex
  • 23. Hexadecimal to Decimal Conversion Convert 3B4F16 to its decimal equivalent: Hex Digits 3 B 4 Fx x x 163 162 161 160 12288 +2816 + 64 +15 15,18310 Positional Values Products x
  • 24. Binary to Hexadecimal Conversion • The easiest method for converting binary to hexadecimal is to use a substitution code • Each hex number converts to 4 binary digits
  • 25. Substitution Code Convert 0101011010101110011010102 to hex using the 4-bit substitution code : 5 6 A E 6 A 0101 0110 1010 1110 0110 1010 56AE6A16
  • 26. Substitution Code Substitution code can also be used to convert binary to octal by using 3-bit groupings: 2 5 5 2 7 1 5 2 010 101 101 010 111 001 101 010 255271528
  • 27. Complementary Arithmetic • 1’s complement – Switch all 0’s to 1’s and 1’s to 0’s Binary # 10110011 1’s complement 01001100
  • 28. Complementary Arithmetic • 2’s complement – Step 1: Find 1’s complement of the number Binary # 11000110 1’s complement 00111001 – Step 2: Add 1 to the 1’s complement 00111001 + 00000001 00111010
  • 29. Signed Magnitude Numbers 110010.. …00101110010101 Sign bit 0 = positive 1 = negative 31 bits for magnitude This is your basic Integer format
  • 30. Sign-Magnitude • Left most bit is sign bit – 0 means positive – 1 means negative • +18 = 00010010 • -18 = 10010010 • The general case can be expressed as follows • Problems ü = å a if a 2 0 - – Need to consider both sign and magnitude in arithmetic – Two representations of zero (+0 and -0) +010 = 00000000 -010 = 10000000 ï ïþ ï ïý ï ïî ï ïí ì - = = å = - - = - 2 0 1 2 0 1 2 1 n i i n i n i i n i a if a A
  • 31. Negation (Sign Magnitude Representation) • In sign magnitude representation, the sign bit is inverted for forming negative of an integer. – For 8 bit sign magnitude representation +1810 = 00010010 -1810 = 10010010 – For 16 bit sign magnitude representation +1810 =0000000000010010 -1810 =1000000000010010
  • 32. Two’s Compliment • The general expression for two’s complement representation is A n a a • +3 = 00000011 • +2 = 00000010 • +1 = 00000001 • +0 = 00000000 • -1 = 11111111 • -2 = 11111110 • -3 = 11111101 å- 2 1 2 = = - - + - 2 0 1 n i i i n
  • 33. Negation (Twos Complement Representation) • In twos complement representation, negation of an integer can be formed with following rules. – Take the Boolean complement of each bir of integer (including sign bit). – Add 1 treating the result as an unsigned integer. • The two step process is referred to as twos complement operation. +18=00010010 Bitwise Complement =11101101 + 1 11101110= -18
  • 34. Negation Special Case 1 • The negation of 0 is 0. 0 = 00000000 Bitwise not 11111111 Add 1 to LSB +1 Result 100000000=0 • Overflow is ignored, so: • The result of negation of 0 is 0.
  • 35. Negation Special Case 2 • The negation of the bit pattern followed by n-1 zeros results back the same number. -128 = 10000000 Bitwise not 01111111 Add 1 to LSB +1 Result 10000000=-128 • Monitor MSB (sign bit) • It should change during negation • Such anomaly is unavoidable.
  • 36. Value Box for Conversion between Twos Complement Binary and Decimal -128 64 32 16 8 4 2 1 An Eight Position Twos Complement Value Box -128 64 32 16 8 4 2 1 1 0 0 0 0 0 1 1 -128 +2 +1 =-125 Converting Binary 10000011 to Decimal -128 64 32 16 8 4 2 1 1 0 0 0 1 0 0 0 -128 +8 =-120 Converting Decimal -120 to Binary
  • 37. Conversion Between Lengths • Positive number pack with leading zeros +18 = 00010010 +18 = 00000000 00010010 • Negative numbers pack with leading ones -18 = 10010010 -18 = 11111111 10010010 • i.e. pack with MSB (sign bit)
  • 38. Addition and Subtraction • Normal binary addition • Monitor sign bit for overflow • Take twos compliment of subtrahend and add to minuend – i.e. a - b = a + (-b) • So we only need addition and complement circuits
  • 39. Addition and Subtraction (Examples) • Additionn of Numbers in Twos Complement (a) (+3) + (+4) 0011 + 0100 0111 = 7 (b) (-7) + (+5) 1001 + 0101 1110 =-2 (c) (-4) + (-1) 1100 + 1111 11011 =-5 (d) (-4) + (+4) 1100 +0100 10000 =0 (e) (+5) + (+4) 0101 +0100 1001 =Overflow (f) (-7) + (-6) 1001 +1010 10011 =Overflow
  • 40. Addition and Subtraction (Examples) • Subtraction of Numbers in Twos Complement (a) (+2) – (+7) 0010 + 1001 1011 = -5 (b) (+5) - (+2) 0101 + 1110 1011 =3 (c) (-5) - (+2) 1011 + 1110 11001 =-7 (d) (+5) - (-2) 0101 +0010 0111 =7 (e) (+7) - (-7) 0111 +0111 1100 =Overflow (f) (-6) - (+4) 1010 +1100 10110 =Overflow
  • 41. Hardware for Addition and Subtraction