Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Binary Subtraction and Two's Complement, Slides of Digital Logic Design and Programming

An explanation of binary subtraction, including the concept of borrowing, subtraction circuits, and the use of incrementers and decrementers. It also introduces the concept of two's complement for representing negative numbers in binary systems. Examples and a table of 2's complement values for 4 bits.

Typology: Slides

2012/2013

Uploaded on 05/07/2013

anjushree
anjushree 🇮🇳

4.3

(53)

150 documents

1 / 18

Related documents


Partial preview of the text

Download Binary Subtraction and Two's Complement and more Slides Digital Logic Design and Programming in PDF only on Docsity! Binary additon & subtraction Docsity.com Class 18 – Subtraction • Binary Addition and Subtraction • Subtraction circuits • Incrementer, Decrementer • Material from section 4-3 and 4-4 of text Docsity.com In General • When there is no borrow into the msb position, then the subtrahend in not larger than the minuend and the result is positive and correct. • If a borrow into the msb does occur, then the subtrahend is larger than the minuend. This was seen back in lecture 2. Docsity.com Consider • Now do the operation 4 – 6 • Correct difference is -2 or -0010 • Different because 2n was brought in and made the operation M-N+2n Docsity.com Desired • Actual desired magnitude is N-M • To get this need to do 2n – (M-N+2)= N-M • Doing the subtraction from 2n gives the correct result. Docsity.com 2’s complement • The 2’s complement is defined as 2n-N • Can be done by subtraction of N from 2n or adding 1 to the 1’s complement of a number. • For 6 = 0110 – The 1’s complement is 1001 – The 2’s complement is 1010 Docsity.com Operation with 2’s complement • Add 4 and -6 • Will use the 2’s complement of -6 or 1010 – 4 0100 – -6 1010 – 1110 • And taking the 2’s complement of 1110 get 0001 + 1 = 0010 Docsity.com A 2’s complement table for 4 bits • Listing the values represented. Docsity.com Overflow • When adding 2 n-bit numbers it is possilbe to get a n+1 bit result if there is a carry out. • On paper it is easy just add another bit. • In 2’s complement add a msb 0 for a positive or a msb 1 for a negative. • In a computer the number of bits that can be used is fixed. Docsity.com Overflow indication. • In 8-bit 2’s complement notation the range that can be represented is -127 to +127. • Then the operation to add +70 to +80 is – Carries 0 1 – +70 0 100 0110 – +80 0 101 0000 – +150 1 001 0110 • Also look at the addition of -70 and -80 Docsity.com The other addition • The addition of -70 and -80 – Carries 1 0 – -70 1 011 1010 – -80 1 011 0000 – -150 0 110 1010 • The rule – if the carry into the msb position differs from the carry out from the msb position then an overflow has occurred. • The circuit • . Docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved