SlideShare a Scribd company logo
1 of 17
COMPUTER LOGIC
PART 1
LOGIC OF COMPUTER ARITHMETIC OPERATIONS
ACCORDING TO
Матвієнко М.П. Комп’ютерна логіка. Навчальний посібник.—
K.: Видавництво Лipa-K, 2012. — 288 с.
ISBN 966-2609-09- 7
AGENDA
What Logic is
Number Systems
Arithmetic operations over binary numbers
Number representation by signed, one’s, two’s
compliment and modified codes
The logic of adding and subtracting binary numbers
1.1. Number Systems
• Definition 1.1.1. A number system is a system of displaying any numbers
using a limited number of digits.
Depending on the ways of displaying numbers with digits, number systems
are divided into positional and non-positional.
• Definition 1.1.2. A non-positional number system is a system in which the
quantitative value of each digit does not depend on the place in the display of
the number, but is determined only by the number symbol itself. So, for
example, the number 30 of the decimal numbering system in the Roman non-
positional system is denoted as the number XXX, which has the same symbol
X in all digits, which means 10 units, regardless of its position in the display of
the number.
• Definition 1.1.3. A positional numbering system is a system in which the
quantitative value of each digit depends on its place in the display of the
number.
• Definition 1.1.4. The number of digit used to display a number in the
positional numbering system is called the basis of the numbering system .
1.1. Number Systems
• Any number that satisfies the condition d>2 is the basis of the counting system d.
In the binary numbering system d = 2 and to represent numbers you use symbols (1, 0),
in octal d = 8 and to represent numbers you use symbols (0, 1, 2, 3, 4, 5, 6, 7), and in
hexadecimal, d = 16, and for the representation of numbers, the symbols are (0, 1, 2, 3,
4, 5, 6, 7, 8, 9, A, B, C, DI, E, P), where A = 10 ; B = 11; C= 12; D= 13; E= 14: F= 15.
• The binary number system is the main number system in which arithmetic and logical
operations are performed in computers, because two-position electronic elements are
widely used for its technical implementation.
• The conversion of numbers from the decimal numbering system to binary, octal and
hexadecimal and vice versa is of significant importance when performing arithmetic and
logical operations in computers. To convert whole numbers, the algorithm of dividing a
given number by the basis of the number, into whose system it is converted, is most
often used.
1.1. Number Systems
The algorithm has the following steps:
1. Divide the number to be translated in the number system with the base d into the base
p according to the rule of the number system with the base d.
2. Check whether the remain is not equal to zero. If it is not equal, then take it as a new
number and return to step 1.
3. If the remain is equal zero, then write out all the obtained remainders from the division
in the reverse order of their receipt.
4. The resulting entry is the entry of a number in the number system with the base p.
Example. Convert the number 13(10) from the decimal system to binary
13(10) = 1101(2)
1*23+1*22+0*21+1*20
1.1. Number Systems
To convert fractional numbers, use the algorithm of multiplying a given number by
the base of the number into which it will be converted. This algorithm has the following
steps.
1. Multiply the fractional number with the base q by the base of the number system p,
into which it is converted.
2. In each result, select integer parts, if any.
3. The highlighted whole parts of the product and are the digits of the fractional part of the
number.
Example. Convert the number 0.45 (10) from the decimal number system to binary with an
accuracy of 10-4 and check the solution.
The solution. According to the algorithm for converting fractional numbers, we
successively multiply the fractional number 0.45 of the decimal numbering system by the
base of the binary numbering system four times, as a result of which we get
0,45 0,90 0,80 0,60
x x x x
2 2 2 2
------- ------- -------- ---------
0,90 1,80 1,60 1,20 45(10) = 0,0111(2)
1.2. Arithmetic operations over binary numbers
Four arithmetic operations to the binary counting system (addition,
subtraction, multiplication and division) are considered.
Addition. When adding binary numbers, you must use the following rules
a) 0 + 0 = 0; b) 0+1=1; c) 1+0=11; d) 1+ 1= 10 (1.2.1)
A two-digit sum of addition in d) means that when adding binary digits that are equal to 1,
there is a transfer of 1 to the next higher digit. This carry must be added to the sum of the
digits that are formed in the adjacent digit on the left.
Example. Add two binary numbers A1 = 1101101 and A2= 1001111.
The solution: accordance with 1.2.1, we perform bit-by-bit addition binary numbers A1
and A2
1.2. Arithmetic operations over binary numbers
Substruction. When subsruction binary numbers, you must use the following
rules
a) 0 - 0 = 0; b) 1 – 0 =1; c) 1 – 1 =0; d) 10 – 1 = 1 (1.2.2)
In addition, it is necessary to remember that
1000...0 - 1 = 111..1 . (1.2.3)
n zeros
Example. Substruction two binary numbers A1 = 11000011 and A2= 10100111.
There was no need use borrow for lower two bits.
For the third bit, it is made borrow from the seventh digit (closest non-zero bit).
In the intermediate bit, the subtraction takes place from one (1.2.3).
1.2. Arithmetic operations over binary numbers
Multiplication. Multiplying two binary numbers is done in the same way as
multiplying two decimal numbers. That is, the product is successively multiplied by
each digit of the multiplier, starting with the youngest or the oldest. To take into account
the weight of the corresponding digit of the factor, the result moves either to the left, if the
multiplication occurs starting from the lowest digit of the factor, or to the right, if the
multiplication occurs starting from the highest digit of the factor. At the same time, the
movement takes place on the corresponding number of digits the digit of the multiplier is
shifted relative to its lower or higher digit. Obtained as a result of multiplication and shift
partial products after addition give the full result of multiplication.
Example Multiply two binary numbers A1 = 10101 and A2 = 1011 shift left and right.
The solution. In accordance with the we will have:
Shift left Shift right
1.2. Arithmetic operations over binary numbers
Division. Division of binary numbers is similar to division of decimal numbers in
many ways. In computers, as a rule, the "school" algorithm for dividing numbers is
implemented. The "school" division algorithm consists in the fact that the divisor at each
step is subtracted from the divided as many times (starting with the highest digits) as
possible to obtain the smallest positive remainder. Then, a number equal to the number
of divisors contained in the dividend at this step is written in the next digit of the quotient.
In other words, during division, the subtraction operation is repeated until the thing being
reduced becomes less than what is being subtracted. The number of these repetitions
shows how many times the denominator is placed in the decrement.
Example. Perform division of two binary numbers A1 = = 110111 and A2 = 10010 under
the condition that in one case the divisor is A1 and a divisor of A 2, and in the other - vice
versa
1.3. Number representation by signed, one’s, two’s
compliment and modified codes
Arithmetic operations in computers performing using numbers encoded with special
machine codes. There are several types of such codes - signed, one’s compliment , two’s
compliment and modified codes which allow you to replace the subtraction operation with the
addition operation, which simplifies the arithmetic logic device of the computer. Signed code is
based on representing numbers in their form absolute value with plus or minus sign code.
Signed code (прямий код) is based on representing numbers in their form absolute value
with plus or minus sign. The formula for finding the signed code of the binary number
most significant bit, MSb least significant bit, LSb (0 has two different representation)
1.3. Number representation by signed, one’s, two’s
compliment and modified codes
Two’s compliment (обернений/зворотній) code. Formula for displaying two’s compliment
code binary number A has the for:
According tj the formula one’s compliment of the positive number is coincides with one’s
compliment of the positive code. One’s compliment of the negative have 1 in the sign digit,
and in all numerical digits in rows, zeros must be replaced by ones, and ones - by zeros.
There is no negative zero in the additional code.
There is no negative zero in the one’s compliment code.
1.3. Number representation by signed, one’s, two’s
compliment and modified codes
One’s compliment (додатковий) code. Formula for displaying one’s compliment code
binary number A has the for:
According tj the formula one’s compliment of the positive number is coincides with one’s
compliment of the positive code. One’s compliment of the negative have 1 in the sign digit,
and in all numerical digits in rows, zeros must be replaced by ones, and ones - by zeros and
1 must be added to the lower.
There is negative zero in the one’s compliment code.
1.3. Number representation by signed, one’s, two’s
compliment and modified codes
Modified codes. These codes are used for detection bit grid overflow that can occur when
adding binary numbers. Modified codes are different from simple ones machine codes by the
fact that they are assigned to display the sign in them two categories. A plus is represented by
two zeros, and a minus by two ones.
1.4. The logic of adding and subtracting binary numbers
Adding fixed-point numbers in a modified two’s compliment code makes according to the
rules of binary arithmetic. A carry that occurs in the most significant bit is rejected. The sign
digit of the number is the second from the left from the decimal point, and the first one is used
for overflow analysis bit grid.
Example. Add the binary numbers A1 and A2 represented in the modified two's complement
code where:
1.4. The logic of adding and subtracting binary numbers
Adding fixed-point numbers in a modified one’s compliment code is performed same as in
the two’s compliment code. is performed as in the additional code. Difference consists only in
the fact that the carrier from the higher sign bit (if it exist) must be added to the lower bit of the
sum.
Example. Add the binary numbers A1 and A2 represented in the modified one's complement
code where:
1.4. The logic of adding and subtracting binary numbers
Overflow when adding in modified codes are detected by comparing sign bit of the sum.

More Related Content

Similar to Computer arithmetic operations.pptx

FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...Arti Parab Academics
 
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...ARVIND PANDE
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesDr. Anita Goel
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdfmiftah88
 
Data representation
Data representationData representation
Data representationMysore
 
Manoch1raw 160512091436
Manoch1raw 160512091436Manoch1raw 160512091436
Manoch1raw 160512091436marangburu42
 
index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...mayurjagdale4
 
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdfCDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdfshubhangisonawane6
 
Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...mayurjagdale4
 
Data repersentation.
Data repersentation.Data repersentation.
Data repersentation.Ritesh Saini
 

Similar to Computer arithmetic operations.pptx (20)

FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
 
Okkkkk
OkkkkkOkkkkk
Okkkkk
 
NUMBER SYSTEM.pptx
NUMBER  SYSTEM.pptxNUMBER  SYSTEM.pptx
NUMBER SYSTEM.pptx
 
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemes
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdf
 
Data representation in computers
Data representation in computersData representation in computers
Data representation in computers
 
Data representation
Data representationData representation
Data representation
 
Number_Systems (2).ppt
Number_Systems (2).pptNumber_Systems (2).ppt
Number_Systems (2).ppt
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
 
Number System
Number SystemNumber System
Number System
 
Alu1
Alu1Alu1
Alu1
 
Manoch1raw 160512091436
Manoch1raw 160512091436Manoch1raw 160512091436
Manoch1raw 160512091436
 
index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...
 
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdfCDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
 
Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...
 
digital-180612132737.pdf
digital-180612132737.pdfdigital-180612132737.pdf
digital-180612132737.pdf
 
UNIT 1 (1).pptx
UNIT 1 (1).pptxUNIT 1 (1).pptx
UNIT 1 (1).pptx
 
Data repersentation.
Data repersentation.Data repersentation.
Data repersentation.
 
Data Representation
Data RepresentationData Representation
Data Representation
 

Recently uploaded

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 

Recently uploaded (20)

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 

Computer arithmetic operations.pptx

  • 1. COMPUTER LOGIC PART 1 LOGIC OF COMPUTER ARITHMETIC OPERATIONS ACCORDING TO Матвієнко М.П. Комп’ютерна логіка. Навчальний посібник.— K.: Видавництво Лipa-K, 2012. — 288 с. ISBN 966-2609-09- 7
  • 2. AGENDA What Logic is Number Systems Arithmetic operations over binary numbers Number representation by signed, one’s, two’s compliment and modified codes The logic of adding and subtracting binary numbers
  • 3. 1.1. Number Systems • Definition 1.1.1. A number system is a system of displaying any numbers using a limited number of digits. Depending on the ways of displaying numbers with digits, number systems are divided into positional and non-positional. • Definition 1.1.2. A non-positional number system is a system in which the quantitative value of each digit does not depend on the place in the display of the number, but is determined only by the number symbol itself. So, for example, the number 30 of the decimal numbering system in the Roman non- positional system is denoted as the number XXX, which has the same symbol X in all digits, which means 10 units, regardless of its position in the display of the number. • Definition 1.1.3. A positional numbering system is a system in which the quantitative value of each digit depends on its place in the display of the number. • Definition 1.1.4. The number of digit used to display a number in the positional numbering system is called the basis of the numbering system .
  • 4. 1.1. Number Systems • Any number that satisfies the condition d>2 is the basis of the counting system d. In the binary numbering system d = 2 and to represent numbers you use symbols (1, 0), in octal d = 8 and to represent numbers you use symbols (0, 1, 2, 3, 4, 5, 6, 7), and in hexadecimal, d = 16, and for the representation of numbers, the symbols are (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, DI, E, P), where A = 10 ; B = 11; C= 12; D= 13; E= 14: F= 15. • The binary number system is the main number system in which arithmetic and logical operations are performed in computers, because two-position electronic elements are widely used for its technical implementation. • The conversion of numbers from the decimal numbering system to binary, octal and hexadecimal and vice versa is of significant importance when performing arithmetic and logical operations in computers. To convert whole numbers, the algorithm of dividing a given number by the basis of the number, into whose system it is converted, is most often used.
  • 5. 1.1. Number Systems The algorithm has the following steps: 1. Divide the number to be translated in the number system with the base d into the base p according to the rule of the number system with the base d. 2. Check whether the remain is not equal to zero. If it is not equal, then take it as a new number and return to step 1. 3. If the remain is equal zero, then write out all the obtained remainders from the division in the reverse order of their receipt. 4. The resulting entry is the entry of a number in the number system with the base p. Example. Convert the number 13(10) from the decimal system to binary 13(10) = 1101(2) 1*23+1*22+0*21+1*20
  • 6. 1.1. Number Systems To convert fractional numbers, use the algorithm of multiplying a given number by the base of the number into which it will be converted. This algorithm has the following steps. 1. Multiply the fractional number with the base q by the base of the number system p, into which it is converted. 2. In each result, select integer parts, if any. 3. The highlighted whole parts of the product and are the digits of the fractional part of the number. Example. Convert the number 0.45 (10) from the decimal number system to binary with an accuracy of 10-4 and check the solution. The solution. According to the algorithm for converting fractional numbers, we successively multiply the fractional number 0.45 of the decimal numbering system by the base of the binary numbering system four times, as a result of which we get 0,45 0,90 0,80 0,60 x x x x 2 2 2 2 ------- ------- -------- --------- 0,90 1,80 1,60 1,20 45(10) = 0,0111(2)
  • 7. 1.2. Arithmetic operations over binary numbers Four arithmetic operations to the binary counting system (addition, subtraction, multiplication and division) are considered. Addition. When adding binary numbers, you must use the following rules a) 0 + 0 = 0; b) 0+1=1; c) 1+0=11; d) 1+ 1= 10 (1.2.1) A two-digit sum of addition in d) means that when adding binary digits that are equal to 1, there is a transfer of 1 to the next higher digit. This carry must be added to the sum of the digits that are formed in the adjacent digit on the left. Example. Add two binary numbers A1 = 1101101 and A2= 1001111. The solution: accordance with 1.2.1, we perform bit-by-bit addition binary numbers A1 and A2
  • 8. 1.2. Arithmetic operations over binary numbers Substruction. When subsruction binary numbers, you must use the following rules a) 0 - 0 = 0; b) 1 – 0 =1; c) 1 – 1 =0; d) 10 – 1 = 1 (1.2.2) In addition, it is necessary to remember that 1000...0 - 1 = 111..1 . (1.2.3) n zeros Example. Substruction two binary numbers A1 = 11000011 and A2= 10100111. There was no need use borrow for lower two bits. For the third bit, it is made borrow from the seventh digit (closest non-zero bit). In the intermediate bit, the subtraction takes place from one (1.2.3).
  • 9. 1.2. Arithmetic operations over binary numbers Multiplication. Multiplying two binary numbers is done in the same way as multiplying two decimal numbers. That is, the product is successively multiplied by each digit of the multiplier, starting with the youngest or the oldest. To take into account the weight of the corresponding digit of the factor, the result moves either to the left, if the multiplication occurs starting from the lowest digit of the factor, or to the right, if the multiplication occurs starting from the highest digit of the factor. At the same time, the movement takes place on the corresponding number of digits the digit of the multiplier is shifted relative to its lower or higher digit. Obtained as a result of multiplication and shift partial products after addition give the full result of multiplication. Example Multiply two binary numbers A1 = 10101 and A2 = 1011 shift left and right. The solution. In accordance with the we will have: Shift left Shift right
  • 10. 1.2. Arithmetic operations over binary numbers Division. Division of binary numbers is similar to division of decimal numbers in many ways. In computers, as a rule, the "school" algorithm for dividing numbers is implemented. The "school" division algorithm consists in the fact that the divisor at each step is subtracted from the divided as many times (starting with the highest digits) as possible to obtain the smallest positive remainder. Then, a number equal to the number of divisors contained in the dividend at this step is written in the next digit of the quotient. In other words, during division, the subtraction operation is repeated until the thing being reduced becomes less than what is being subtracted. The number of these repetitions shows how many times the denominator is placed in the decrement. Example. Perform division of two binary numbers A1 = = 110111 and A2 = 10010 under the condition that in one case the divisor is A1 and a divisor of A 2, and in the other - vice versa
  • 11. 1.3. Number representation by signed, one’s, two’s compliment and modified codes Arithmetic operations in computers performing using numbers encoded with special machine codes. There are several types of such codes - signed, one’s compliment , two’s compliment and modified codes which allow you to replace the subtraction operation with the addition operation, which simplifies the arithmetic logic device of the computer. Signed code is based on representing numbers in their form absolute value with plus or minus sign code. Signed code (прямий код) is based on representing numbers in their form absolute value with plus or minus sign. The formula for finding the signed code of the binary number most significant bit, MSb least significant bit, LSb (0 has two different representation)
  • 12. 1.3. Number representation by signed, one’s, two’s compliment and modified codes Two’s compliment (обернений/зворотній) code. Formula for displaying two’s compliment code binary number A has the for: According tj the formula one’s compliment of the positive number is coincides with one’s compliment of the positive code. One’s compliment of the negative have 1 in the sign digit, and in all numerical digits in rows, zeros must be replaced by ones, and ones - by zeros. There is no negative zero in the additional code. There is no negative zero in the one’s compliment code.
  • 13. 1.3. Number representation by signed, one’s, two’s compliment and modified codes One’s compliment (додатковий) code. Formula for displaying one’s compliment code binary number A has the for: According tj the formula one’s compliment of the positive number is coincides with one’s compliment of the positive code. One’s compliment of the negative have 1 in the sign digit, and in all numerical digits in rows, zeros must be replaced by ones, and ones - by zeros and 1 must be added to the lower. There is negative zero in the one’s compliment code.
  • 14. 1.3. Number representation by signed, one’s, two’s compliment and modified codes Modified codes. These codes are used for detection bit grid overflow that can occur when adding binary numbers. Modified codes are different from simple ones machine codes by the fact that they are assigned to display the sign in them two categories. A plus is represented by two zeros, and a minus by two ones.
  • 15. 1.4. The logic of adding and subtracting binary numbers Adding fixed-point numbers in a modified two’s compliment code makes according to the rules of binary arithmetic. A carry that occurs in the most significant bit is rejected. The sign digit of the number is the second from the left from the decimal point, and the first one is used for overflow analysis bit grid. Example. Add the binary numbers A1 and A2 represented in the modified two's complement code where:
  • 16. 1.4. The logic of adding and subtracting binary numbers Adding fixed-point numbers in a modified one’s compliment code is performed same as in the two’s compliment code. is performed as in the additional code. Difference consists only in the fact that the carrier from the higher sign bit (if it exist) must be added to the lower bit of the sum. Example. Add the binary numbers A1 and A2 represented in the modified one's complement code where:
  • 17. 1.4. The logic of adding and subtracting binary numbers Overflow when adding in modified codes are detected by comparing sign bit of the sum.