SlideShare a Scribd company logo
MBA admission in India 
By: 
Admission.edhole.com
Binary numbers and arithmetic 
Admission.edhole.com
addition 
Admission.edhole.com
Addition (decimal) 
1 
 
4 
5 
5 
14 
19 
 
5 1 
 
5 
10 
6 1 
 
5 
11 
1 1 
12 
99 
 
111 
Admission.edhole.com
Addition (binary) 
0 
 
0 
0 
1 
 
0 
1 
0 
 
1 
1 
1 
1 
1 
10 
Admission.edhole.com
Addition (binary) 
1 1 1 1 
01101 
01011 
11000 
 
Admission.edhole.com
Addition (binary) 
0 
 
0 
1 
 
0 
So ca0n we count in 1 
binary? 
0 
 
1 
1 
1 
1 
1 
10 
Admission.edhole.com
Counting in binary (4 bits) 
0 
0000 
1 
0001 
2 
… 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
Admission.edhole.com
multiplication 
Admission.edhole.com
Multiplication (decimal) 
13 
11 
13 
130 
143 
 
 
Admission.edhole.com
Multiplication (binary) 
1101 
1011 
1101 
 
11010 
1101000 
 
10001111 
Admission.edhole.com
Multiplication (binary) 
1101 
1011 
1101 
 
11010 
1101000 
 
10001111 
It’s interesting to note 
that binary multiplication 
is a sequence of shifts 
and adds of the first 
term (depending on the 
bits in the second term. 
110100 is missing here 
because the 
corresponding bit in the 
second terms is 0. 
Admission.edhole.com
Representing signed (positive 
and negative) numbers
Representing numbers (ints) 
 Fixed, finite number of bits. 
bits bytes C/C++ Intel Sun 
8 1 char [s]byte byte 
16 2 short [s]word half 
32 4 int or long [s]dword word 
64 8 long long [s]qword xword
Representing numbers (ints) 
 Fixed, finite number of bits. 
bits Intel signed unsigned 
8 [s]byte -27..+27-1 0..+28-1 
16 [s]word -215..+215-1 0..+216-1 
32 [s]dword -231..+231-1 0..+232-1 
64 [s]qword -263..+263-1 0..+264-1 
In general, for k bits, the unsigned range is [0..+2k-1] and 
the signed range is [-2k-1..+2k-1-1].
Methods for representing signed ints. 
1. signed magnitude 
2. 1’s complement (diminished radix complement) 
3. 2’s complement (radix complement) 
4. excess bD-1
Signed magnitude 
 Ex. 4-bit signed magnitude 
 1 bit for sign 
 3 bits for magnitude 
 N  N 
0 0000 1000 
1 0001 1001 
2 0010 1010 
3 0011 1011 
4 0100 1100 
5 0101 1101 
6 0110 1110 
7 0111 1111
Signed magnitude 
 Ex. 4-bit signed magnitude 
 1 bit for sign 
 3 bits for magnitude 
 N  N 
0 0000 1000 
1 0001 1001 
2 0010 1010 
3 0011 1011 
4 0100 1100 
5 0101 1101 
6 0110 1110 
7 0111 1111
1’s complement 
(diminished radix complement) 
 Let x be a non-negative number. 
 Then –x is represented by bD-1+(-x) where 
b = base 
D = (total) # of bits (including the sign bit) 
 Ex. Let b=2 and D=4. 
Then -1 is represented by 24-1-1 = 1410 or 11102.
1’s complement 
(diminished radix complement) 
 Let x be a non-negative number. 
 Then –x is represented by bD-1+(-x) where 
b = base & D = (total) # of bits (including the sign bit) 
 Ex. What is the 9’s complement of 1238910? 
Given b=10 and D=5. Then the 9’s complement of 12389 
= 105 – 1 – 12389 
= 100000 – 1 – 12389 
= 99999 – 12389 
= 87610
1’s complement 
(diminished radix complement) 
 Let x be a non-negative number. 
 Then –x is represented by bD-1+(-x) 
where 
b = base 
D = (total) # of bits (including the sign 
bit) 
 Shortcut for base 2? 
 All combinations used, but 2 zeros! 
 N  N 
0 0000 1111 
1 0001 1110 
2 0010 1101 
3 0011 1100 
4 0100 1011 
5 0101 1010 
6 0110 1001 
7 0111 1000
2’s complement 
(radix complement) 
 Let x be a non-negative number. 
 Then –x is represented by bD+(-x). 
 Ex. Let b=2 and D=4. Then -1 is represented by 24- 
1 = 15 or 11112. 
 Ex. Let b=2 and D=4. Then -5 is represented by 24 
– 5 = 11 or 10112. 
 Ex. Let b=10 and D=5. Then the 10’s complement 
of 12389 = 105 – 12389 = 100000 – 12389 = 87611.
2’s complement 
(radix complement) 
 Let x be a non-negative number. 
 Then –x is represented by bD+(-x). 
 Ex. Let b=2 and D=4. Then -1 is 
represented by 24-1 = 15 or 11112. 
 Ex. Let b=2 and D=4. Then -5 is 
represented by 24 – 5 = 11 or 10112. 
 Shortcut for base 2? 
 N  N 
0 0000 0000 
1 0001 1111 
2 0010 1110 
3 0011 1101 
4 0100 1100 
5 0101 1011 
6 0110 1010 
7 0111 1001
2’s complement 
(radix complement) 
 Shortcut for base 2? 
 Yes! Flip the bits and add 1. 
 N  N 
0 0000 0000 
1 0001 1111 
2 0010 1110 
3 0011 1101 
4 0100 1100 
5 0101 1011 
6 0110 1010 
7 0111 1001
2’s complement 
(radix complement) 
 Are all combinations of 4 bits used? 
 No. (Now we only have one zero.) 
 1000 is missing! 
 What is 1000? 
 Is it positive or negative? 
 Does -8 + 1 = -7 work in 2’s complement? 
 N  N 
0 0000 0000 
1 0001 1111 
2 0010 1110 
3 0011 1101 
4 0100 1100 
5 0101 1011 
6 0110 1010 
7 0111 1001
excess bD-1 (biased 
representation) 
 For pos, neg, and 0, x is represented by 
bD-1 + x 
 Ex. Let b=2 and D=4. Then the excess 8 (24-1) 
representation for 0 is 8+0 = 8 or 10002. 
 Ex. Let b=2 and D=4. Then excess 8 for -1 is 8 – 
1 = 7 or 01112.
excess bD-1 
 For pos, neg, and 0, x is represented 
by 
bD-1 + x. 
 Ex. Let b=2 and D=4. Then the 
excess 8 (24-1) representation for 0 is 
8+0 = 8 or 10002. 
 Ex. Let b=2 and D=4. Then excess 
8 for -1 is 8 – 1 = 7 or 01112. 
 N  N 
0 1000 1000 
1 1001 0111 
2 1010 0110 
3 1011 0101 
4 1100 0100 
5 1101 0011 
6 1110 0010 
7 1111 0001
2’s complement vs. excess bD-1 
 In 2’s, positives start with 0; in 
excess, positives start with 1. 
 Both have one zero (positive). 
 Remaining bits are the same. 
 N  N 
0 1000 1000 
1 1001 0111 
2 1010 0110 
3 1011 0101 
4 1100 0100 
5 1101 0011 
6 1110 0010 
7 1111 0001
Summary of methods for 
representing signed ints. 
signedMag sComp sComp excess 
1 2 8 
N  n  n  n  n  n  
n 
0 0000 1000 1111 0000 1000 1000 
1 0001 1001 1110 1111 0111 1001 
2 0010 1010 1101 1110 0110 1010 
3 0011 1011 1100 1101 0101 1011 
4 0100 1100 1011 1100 0100 1100 
5 0101 1101 1010 1011 0011 1101 
6 0110 1110 1001 1010 0010 1110 
7 0111 1111 1000 1001 0001 1111 
1000=-8| 0000 unused
Binary arithmetic 
Signed magnitude 
1’s complement 
2’s complement 
Excess K (biased)
Binary Arithmetic 
Signed magnitude
Addition w/ signed magnitude 
algorithm 
 For A - B, change the sign of B and perform addition of 
A + (-B) (as in the next step) 
 For A + B: 
 if (Asign==Bsign) then { R = |A| + |B|; Rsign = Asign; } 
 else if (|A|>|B|) then { R = |A| - |B|; Rsign = Asign; } 
 else if (|A|==|B|) then { R = 0; Rsign = 0; } 
 else { R = |B| - |A|; Rsign = Bsign; } 
 Complicated?
Binary Arithmetic 
2’s complement
Representing numbers (ints) 
using 2’s complement 
 Fixed, finite number of bits. 
bits Intel signed 
8 sbyte -27..+27-1 
16 sword -215..+215-1 
32 sdword -231..+231-1 
64 sqword -263..+263-1 
In general, for k bits, the signed range is [-2k-1..+2k-1-1]. 
So where does the extra negative value come from?
Representing numbers (ints) 
 Fixed, finite number of bits. 
bits Intel signed 
8 sbyte -27..+27-1 
16 sword -215..+215-1 
32 sdword -231..+231-1 
64 sqword -263..+263-1 
In general, for k bits, the signed range 
is 
[-2k-1..+2k-1-1]. 
So where does the extra negative value 
come from? 
 n  n 
0 0000 0000 
1 0001 1111 
2 0010 1110 
3 0011 1101 
4 0100 1100 
5 0101 1011 
6 0110 1010 
7 0111 1001 
8 1000
Addition of 2’s complement 
binary numbers 
 Consider 8-bit 2’s complement binary numbers. 
 Then the msb (bit 7) is the sign bit. If this bit is 0, 
then this is a positive number; if this bit is 1, then 
this is a negative number. 
 Addition of 2 positive numbers. 
 Ex. 40 + 58 = 98 
1 1 1 
00101000 
00111010 
01100010 

Addition of 2’s complement 
binary numbers 
 Consider 8-bit 2’s complement 
binary numbers. 
 Addition of a negative to a 
positive. 
 What are the values of these 2 
terms? 
 -88 and 122 
 -88 + 122 = 34 
1 1 1 1 
10101000 
01111010 
 
1 00100010
So how can we perform subtraction?
Addition of 2’s complement 
binary numbers 
 Consider 8-bit 2’s complement binary numbers. 
 Subtraction is nothing but addition of the 2’s 
complement. 
 Ex. 58 – 40 = 58 + (-40) = 18 
1 1 1 1 
00111010 
11011000 
 
1 00010010 
discard carry
Carry vs. overflow
Addition of 2’s complement 
binary numbers 
 Carry vs. overflow when adding A + B 
 If A and B are of opposite sign, then overflow cannot 
occur. 
 If A and B are of the same sign but the result is of 
the opposite sign, then overflow has occurred (and 
the answer is therefore incorrect). 
 Overflow occurs iff the carry into the sign bit differs from the 
carry out of the sign bit.
Addition of 2’s complement 
binary numbers 
class test { 
public static void main ( String 
args[] ) 
{ 
byte A = 127; 
byte B = 127; 
byte result = (byte)(A + B); 
System.out.println( "A + B = " 
+ result ); 
} 
} 
#include <stdio.h> 
int main ( int argc, char* argv[] ) 
{ 
char A = 127; 
char B = 127; 
char result = (char)(A + B); 
printf( "A + B = %d n", result ); 
return 0; 
} Result = -2 in both 
Java (left) and C++ 
(right). Why?
Addition of 2’s complement 
binary numbers 
class test { 
public static void main ( String 
args[] ) 
{ 
byte A = 127; 
byte B = 127; 
byte result = (byte)(A + B); 
System.out.println( "A + B = " 
+ result ); 
} 
} 
Result = -2 in both Java and 
C++. 
Why? 
What’s 127 as a 2’s 
complement binary number? 
01111111 
 
01111111 
11111110 
What is 111111102? 
Flip the bits: 00000001. 
Then add 1: 00000010.
Binary Arithmetic 
1’s complement
Addition with 1’s complement 
 Note: 1’s complement has two 0’s! 
 1’s complement addition is tricky 
(end-around-carry). 
 N  N 
0 0000 1111 
1 0001 1110 
2 0010 1101 
3 0011 1100 
4 0100 1011 
5 0101 1010 
6 0110 1001 
7 0111 1000
8-bit 1’s complement addition 
 Ex. Let X = A816 and Y = 8616. 
 Calculate Y - X using 1’s complement.
8-bit 1’s complement addition 
 Ex. Let X = A816 and Y = 8616. 
 Calculate Y - X using 1’s complement. 
Y = 1000 01102 = -12110 
X = 1010 10002 = -8710 
~X = 0101 01112 
(Note: C=0 out of msb.) 
1000 0110 
 
0101 0111 
1101 1101 
Y - X = -121 + 87 = -34 (base 10)
8-bit 1’s complement addition 
 Ex. Let X = A816 and Y = 8616. 
 Calculate X - Y using 1’s complement.
8-bit 1’s complement addition 
 Ex. Let X = A816 and Y = 8616. 
 Calculate X - Y using 1’s complement. 
X = 1010 10002 = -8710 
Y = 1000 01102 = -12110 
~Y = 0111 10012 
(Note: C=1 out of msb.) 
1010 1000 
0111 1001 
 
1 0010 0001 
1 
 
end around 
carry 
0010 0010 
X - Y = -87 + 121 = 34 (base 10)
Binary Arithmetic 
Excess K (biased)
Binary arithmetic and Excess K 
(biased) 
Method: Simply add and then flip the sign bit. 
-1 0111 
+5 1101 
-- ---- 
+4 0100 -> flip sign -> 1100 
+1 1001 
-5 0011 
-- ---- 
-4 1100 -> flip sign -> 0100 
+1 1001 
+5 1101 
-- ---- 
+6 0110 -> flip sign -> 1110 
-1 0111 
-5 0011 
-- ---- 
-6 1010 -> toggle sign -> 0010 
 N  N 
0 1000 1000 
1 1001 0111 
2 1010 0110 
3 1011 0101 
4 1100 0100 
5 1101 0011 
6 1110 0010 
7 1111 0001 
(Not used for integer arithmetic but employed 
in IEEE 754 floating point standard.)

More Related Content

What's hot

FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
Arti Parab Academics
 
data representation
 data representation data representation
data representation
Haroon_007
 
Lec 02 data representation part 2
Lec 02 data representation part 2Lec 02 data representation part 2
Lec 02 data representation part 2Abdul Khan
 
Lec 02 data representation part 1
Lec 02 data representation part 1Lec 02 data representation part 1
Lec 02 data representation part 1Abdul Khan
 
Logic Design
Logic DesignLogic Design
Logic Design
Partha_bappa
 
Binary Arithmetic Operations
Binary Arithmetic OperationsBinary Arithmetic Operations
Binary Arithmetic Operations
Digital System Design
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Dr. Loganathan R
 
Digital Electronics and Computer Language
Digital Electronics and Computer Language Digital Electronics and Computer Language
Digital Electronics and Computer Language
Manthan Chavda
 
dld 01-introduction
dld 01-introductiondld 01-introduction
dld 01-introduction
United International University
 
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009
lionking
 
Objective Questions Digital Electronics
Objective Questions Digital ElectronicsObjective Questions Digital Electronics
Objective Questions Digital Electronics
Nilesh Bhaskarrao Bahadure
 
digital logic design number system
digital logic design number systemdigital logic design number system
digital logic design number system
Nallapati Anindra
 
Code conversion r006
Code conversion r006Code conversion r006
Code conversion r006
arunachalamr16
 
Module 4
Module 4Module 4
Module 4
sadhanakumble
 
Cmp104 lec 2 number system
Cmp104 lec 2 number systemCmp104 lec 2 number system
Cmp104 lec 2 number systemkapil078
 
DIGITAL ELECTRONICS- Number System
DIGITAL ELECTRONICS- Number SystemDIGITAL ELECTRONICS- Number System
DIGITAL ELECTRONICS- Number System
Trinity Dwarka
 
Number System Conversion | BCA
Number System Conversion | BCANumber System Conversion | BCA
Number System Conversion | BCA
Raj vardhan
 
Unit 1 data representation and computer arithmetic
Unit 1  data representation and computer arithmeticUnit 1  data representation and computer arithmetic
Unit 1 data representation and computer arithmetic
AmrutaMehata
 

What's hot (20)

FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
 
data representation
 data representation data representation
data representation
 
Lec 02 data representation part 2
Lec 02 data representation part 2Lec 02 data representation part 2
Lec 02 data representation part 2
 
Lec 02 data representation part 1
Lec 02 data representation part 1Lec 02 data representation part 1
Lec 02 data representation part 1
 
Logic Design
Logic DesignLogic Design
Logic Design
 
Binary Arithmetic Operations
Binary Arithmetic OperationsBinary Arithmetic Operations
Binary Arithmetic Operations
 
Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...Mcs 012 computer organisation and assemly language programming- ignou assignm...
Mcs 012 computer organisation and assemly language programming- ignou assignm...
 
06 floating point
06 floating point06 floating point
06 floating point
 
Digital Electronics and Computer Language
Digital Electronics and Computer Language Digital Electronics and Computer Language
Digital Electronics and Computer Language
 
Pp02
Pp02Pp02
Pp02
 
dld 01-introduction
dld 01-introductiondld 01-introduction
dld 01-introduction
 
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009
 
Objective Questions Digital Electronics
Objective Questions Digital ElectronicsObjective Questions Digital Electronics
Objective Questions Digital Electronics
 
digital logic design number system
digital logic design number systemdigital logic design number system
digital logic design number system
 
Code conversion r006
Code conversion r006Code conversion r006
Code conversion r006
 
Module 4
Module 4Module 4
Module 4
 
Cmp104 lec 2 number system
Cmp104 lec 2 number systemCmp104 lec 2 number system
Cmp104 lec 2 number system
 
DIGITAL ELECTRONICS- Number System
DIGITAL ELECTRONICS- Number SystemDIGITAL ELECTRONICS- Number System
DIGITAL ELECTRONICS- Number System
 
Number System Conversion | BCA
Number System Conversion | BCANumber System Conversion | BCA
Number System Conversion | BCA
 
Unit 1 data representation and computer arithmetic
Unit 1  data representation and computer arithmeticUnit 1  data representation and computer arithmetic
Unit 1 data representation and computer arithmetic
 

Similar to Mba admission in india

Mba admission in india
Mba admission in indiaMba admission in india
Mba admission in india
Edhole.com
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
Suganthi Vasanth Raj
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
ssuser52a19e
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
RAJKUMARP63
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
MarlonMagtibay2
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and Hexadecimal
UtkirjonUbaydullaev1
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
RabiaAsif31
 
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
 
Number system
Number systemNumber system
Number system
Mantra VLSI
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
MUNAZARAZZAQELEA
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdf
RameshK531901
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
Surendra Loya
 
Number system and codes
Number system and codesNumber system and codes
Number system and codes
Abhiraj Bohra
 
Digital_Electronics_Basics.pdf
Digital_Electronics_Basics.pdfDigital_Electronics_Basics.pdf
Digital_Electronics_Basics.pdf
rahul143341
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
skatiarrahaman
 
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptChapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
David Louie Bedia
 
Unit 1 PDF.pptx
Unit 1 PDF.pptxUnit 1 PDF.pptx
Unit 1 PDF.pptx
ChandraV13
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptx
sulekhasaxena2
 

Similar to Mba admission in india (20)

Mba admission in india
Mba admission in indiaMba admission in india
Mba admission in india
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and Hexadecimal
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
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
 
Number system
Number systemNumber system
Number system
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
unit-i-number-systems.pdf
unit-i-number-systems.pdfunit-i-number-systems.pdf
unit-i-number-systems.pdf
 
Number system
Number systemNumber system
Number system
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
 
Number system and codes
Number system and codesNumber system and codes
Number system and codes
 
Digital_Electronics_Basics.pdf
Digital_Electronics_Basics.pdfDigital_Electronics_Basics.pdf
Digital_Electronics_Basics.pdf
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
2's complement
2's complement2's complement
2's complement
 
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.pptChapter_1_Digital_Systems_and_Binary_Numbers2.ppt
Chapter_1_Digital_Systems_and_Binary_Numbers2.ppt
 
Unit 1 PDF.pptx
Unit 1 PDF.pptxUnit 1 PDF.pptx
Unit 1 PDF.pptx
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptx
 

More from Edhole.com

Ca in patna
Ca in patnaCa in patna
Ca in patna
Edhole.com
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
Edhole.com
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
Edhole.com
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
Edhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
Edhole.com
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
Edhole.com
 
Website dsigning company in india
Website dsigning company in indiaWebsite dsigning company in india
Website dsigning company in india
Edhole.com
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
Edhole.com
 
Ca in patna
Ca in patnaCa in patna
Ca in patna
Edhole.com
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
Edhole.com
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
Edhole.com
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
Edhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
Edhole.com
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
Edhole.com
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
Edhole.com
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
Edhole.com
 
Website designing company in mumbai
Website designing company in mumbaiWebsite designing company in mumbai
Website designing company in mumbai
Edhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
Edhole.com
 
Website desinging company in surat
Website desinging company in suratWebsite desinging company in surat
Website desinging company in surat
Edhole.com
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
Edhole.com
 

More from Edhole.com (20)

Ca in patna
Ca in patnaCa in patna
Ca in patna
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
 
Website dsigning company in india
Website dsigning company in indiaWebsite dsigning company in india
Website dsigning company in india
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
 
Ca in patna
Ca in patnaCa in patna
Ca in patna
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
 
Website designing company in mumbai
Website designing company in mumbaiWebsite designing company in mumbai
Website designing company in mumbai
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website desinging company in surat
Website desinging company in suratWebsite desinging company in surat
Website desinging company in surat
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
 

Recently uploaded

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 

Recently uploaded (20)

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 

Mba admission in india

  • 1. MBA admission in India By: Admission.edhole.com
  • 2. Binary numbers and arithmetic Admission.edhole.com
  • 4. Addition (decimal) 1  4 5 5 14 19  5 1  5 10 6 1  5 11 1 1 12 99  111 Admission.edhole.com
  • 5. Addition (binary) 0  0 0 1  0 1 0  1 1 1 1 1 10 Admission.edhole.com
  • 6. Addition (binary) 1 1 1 1 01101 01011 11000  Admission.edhole.com
  • 7. Addition (binary) 0  0 1  0 So ca0n we count in 1 binary? 0  1 1 1 1 1 10 Admission.edhole.com
  • 8. Counting in binary (4 bits) 0 0000 1 0001 2 … 3 4 5 6 7 8 9 10 11 12 13 14 15 Admission.edhole.com
  • 10. Multiplication (decimal) 13 11 13 130 143   Admission.edhole.com
  • 11. Multiplication (binary) 1101 1011 1101  11010 1101000  10001111 Admission.edhole.com
  • 12. Multiplication (binary) 1101 1011 1101  11010 1101000  10001111 It’s interesting to note that binary multiplication is a sequence of shifts and adds of the first term (depending on the bits in the second term. 110100 is missing here because the corresponding bit in the second terms is 0. Admission.edhole.com
  • 13. Representing signed (positive and negative) numbers
  • 14. Representing numbers (ints)  Fixed, finite number of bits. bits bytes C/C++ Intel Sun 8 1 char [s]byte byte 16 2 short [s]word half 32 4 int or long [s]dword word 64 8 long long [s]qword xword
  • 15. Representing numbers (ints)  Fixed, finite number of bits. bits Intel signed unsigned 8 [s]byte -27..+27-1 0..+28-1 16 [s]word -215..+215-1 0..+216-1 32 [s]dword -231..+231-1 0..+232-1 64 [s]qword -263..+263-1 0..+264-1 In general, for k bits, the unsigned range is [0..+2k-1] and the signed range is [-2k-1..+2k-1-1].
  • 16. Methods for representing signed ints. 1. signed magnitude 2. 1’s complement (diminished radix complement) 3. 2’s complement (radix complement) 4. excess bD-1
  • 17. Signed magnitude  Ex. 4-bit signed magnitude  1 bit for sign  3 bits for magnitude  N  N 0 0000 1000 1 0001 1001 2 0010 1010 3 0011 1011 4 0100 1100 5 0101 1101 6 0110 1110 7 0111 1111
  • 18. Signed magnitude  Ex. 4-bit signed magnitude  1 bit for sign  3 bits for magnitude  N  N 0 0000 1000 1 0001 1001 2 0010 1010 3 0011 1011 4 0100 1100 5 0101 1101 6 0110 1110 7 0111 1111
  • 19. 1’s complement (diminished radix complement)  Let x be a non-negative number.  Then –x is represented by bD-1+(-x) where b = base D = (total) # of bits (including the sign bit)  Ex. Let b=2 and D=4. Then -1 is represented by 24-1-1 = 1410 or 11102.
  • 20. 1’s complement (diminished radix complement)  Let x be a non-negative number.  Then –x is represented by bD-1+(-x) where b = base & D = (total) # of bits (including the sign bit)  Ex. What is the 9’s complement of 1238910? Given b=10 and D=5. Then the 9’s complement of 12389 = 105 – 1 – 12389 = 100000 – 1 – 12389 = 99999 – 12389 = 87610
  • 21. 1’s complement (diminished radix complement)  Let x be a non-negative number.  Then –x is represented by bD-1+(-x) where b = base D = (total) # of bits (including the sign bit)  Shortcut for base 2?  All combinations used, but 2 zeros!  N  N 0 0000 1111 1 0001 1110 2 0010 1101 3 0011 1100 4 0100 1011 5 0101 1010 6 0110 1001 7 0111 1000
  • 22. 2’s complement (radix complement)  Let x be a non-negative number.  Then –x is represented by bD+(-x).  Ex. Let b=2 and D=4. Then -1 is represented by 24- 1 = 15 or 11112.  Ex. Let b=2 and D=4. Then -5 is represented by 24 – 5 = 11 or 10112.  Ex. Let b=10 and D=5. Then the 10’s complement of 12389 = 105 – 12389 = 100000 – 12389 = 87611.
  • 23. 2’s complement (radix complement)  Let x be a non-negative number.  Then –x is represented by bD+(-x).  Ex. Let b=2 and D=4. Then -1 is represented by 24-1 = 15 or 11112.  Ex. Let b=2 and D=4. Then -5 is represented by 24 – 5 = 11 or 10112.  Shortcut for base 2?  N  N 0 0000 0000 1 0001 1111 2 0010 1110 3 0011 1101 4 0100 1100 5 0101 1011 6 0110 1010 7 0111 1001
  • 24. 2’s complement (radix complement)  Shortcut for base 2?  Yes! Flip the bits and add 1.  N  N 0 0000 0000 1 0001 1111 2 0010 1110 3 0011 1101 4 0100 1100 5 0101 1011 6 0110 1010 7 0111 1001
  • 25. 2’s complement (radix complement)  Are all combinations of 4 bits used?  No. (Now we only have one zero.)  1000 is missing!  What is 1000?  Is it positive or negative?  Does -8 + 1 = -7 work in 2’s complement?  N  N 0 0000 0000 1 0001 1111 2 0010 1110 3 0011 1101 4 0100 1100 5 0101 1011 6 0110 1010 7 0111 1001
  • 26. excess bD-1 (biased representation)  For pos, neg, and 0, x is represented by bD-1 + x  Ex. Let b=2 and D=4. Then the excess 8 (24-1) representation for 0 is 8+0 = 8 or 10002.  Ex. Let b=2 and D=4. Then excess 8 for -1 is 8 – 1 = 7 or 01112.
  • 27. excess bD-1  For pos, neg, and 0, x is represented by bD-1 + x.  Ex. Let b=2 and D=4. Then the excess 8 (24-1) representation for 0 is 8+0 = 8 or 10002.  Ex. Let b=2 and D=4. Then excess 8 for -1 is 8 – 1 = 7 or 01112.  N  N 0 1000 1000 1 1001 0111 2 1010 0110 3 1011 0101 4 1100 0100 5 1101 0011 6 1110 0010 7 1111 0001
  • 28. 2’s complement vs. excess bD-1  In 2’s, positives start with 0; in excess, positives start with 1.  Both have one zero (positive).  Remaining bits are the same.  N  N 0 1000 1000 1 1001 0111 2 1010 0110 3 1011 0101 4 1100 0100 5 1101 0011 6 1110 0010 7 1111 0001
  • 29. Summary of methods for representing signed ints. signedMag sComp sComp excess 1 2 8 N  n  n  n  n  n  n 0 0000 1000 1111 0000 1000 1000 1 0001 1001 1110 1111 0111 1001 2 0010 1010 1101 1110 0110 1010 3 0011 1011 1100 1101 0101 1011 4 0100 1100 1011 1100 0100 1100 5 0101 1101 1010 1011 0011 1101 6 0110 1110 1001 1010 0010 1110 7 0111 1111 1000 1001 0001 1111 1000=-8| 0000 unused
  • 30. Binary arithmetic Signed magnitude 1’s complement 2’s complement Excess K (biased)
  • 32. Addition w/ signed magnitude algorithm  For A - B, change the sign of B and perform addition of A + (-B) (as in the next step)  For A + B:  if (Asign==Bsign) then { R = |A| + |B|; Rsign = Asign; }  else if (|A|>|B|) then { R = |A| - |B|; Rsign = Asign; }  else if (|A|==|B|) then { R = 0; Rsign = 0; }  else { R = |B| - |A|; Rsign = Bsign; }  Complicated?
  • 34. Representing numbers (ints) using 2’s complement  Fixed, finite number of bits. bits Intel signed 8 sbyte -27..+27-1 16 sword -215..+215-1 32 sdword -231..+231-1 64 sqword -263..+263-1 In general, for k bits, the signed range is [-2k-1..+2k-1-1]. So where does the extra negative value come from?
  • 35. Representing numbers (ints)  Fixed, finite number of bits. bits Intel signed 8 sbyte -27..+27-1 16 sword -215..+215-1 32 sdword -231..+231-1 64 sqword -263..+263-1 In general, for k bits, the signed range is [-2k-1..+2k-1-1]. So where does the extra negative value come from?  n  n 0 0000 0000 1 0001 1111 2 0010 1110 3 0011 1101 4 0100 1100 5 0101 1011 6 0110 1010 7 0111 1001 8 1000
  • 36. Addition of 2’s complement binary numbers  Consider 8-bit 2’s complement binary numbers.  Then the msb (bit 7) is the sign bit. If this bit is 0, then this is a positive number; if this bit is 1, then this is a negative number.  Addition of 2 positive numbers.  Ex. 40 + 58 = 98 1 1 1 00101000 00111010 01100010 
  • 37. Addition of 2’s complement binary numbers  Consider 8-bit 2’s complement binary numbers.  Addition of a negative to a positive.  What are the values of these 2 terms?  -88 and 122  -88 + 122 = 34 1 1 1 1 10101000 01111010  1 00100010
  • 38. So how can we perform subtraction?
  • 39. Addition of 2’s complement binary numbers  Consider 8-bit 2’s complement binary numbers.  Subtraction is nothing but addition of the 2’s complement.  Ex. 58 – 40 = 58 + (-40) = 18 1 1 1 1 00111010 11011000  1 00010010 discard carry
  • 41. Addition of 2’s complement binary numbers  Carry vs. overflow when adding A + B  If A and B are of opposite sign, then overflow cannot occur.  If A and B are of the same sign but the result is of the opposite sign, then overflow has occurred (and the answer is therefore incorrect).  Overflow occurs iff the carry into the sign bit differs from the carry out of the sign bit.
  • 42. Addition of 2’s complement binary numbers class test { public static void main ( String args[] ) { byte A = 127; byte B = 127; byte result = (byte)(A + B); System.out.println( "A + B = " + result ); } } #include <stdio.h> int main ( int argc, char* argv[] ) { char A = 127; char B = 127; char result = (char)(A + B); printf( "A + B = %d n", result ); return 0; } Result = -2 in both Java (left) and C++ (right). Why?
  • 43. Addition of 2’s complement binary numbers class test { public static void main ( String args[] ) { byte A = 127; byte B = 127; byte result = (byte)(A + B); System.out.println( "A + B = " + result ); } } Result = -2 in both Java and C++. Why? What’s 127 as a 2’s complement binary number? 01111111  01111111 11111110 What is 111111102? Flip the bits: 00000001. Then add 1: 00000010.
  • 45. Addition with 1’s complement  Note: 1’s complement has two 0’s!  1’s complement addition is tricky (end-around-carry).  N  N 0 0000 1111 1 0001 1110 2 0010 1101 3 0011 1100 4 0100 1011 5 0101 1010 6 0110 1001 7 0111 1000
  • 46. 8-bit 1’s complement addition  Ex. Let X = A816 and Y = 8616.  Calculate Y - X using 1’s complement.
  • 47. 8-bit 1’s complement addition  Ex. Let X = A816 and Y = 8616.  Calculate Y - X using 1’s complement. Y = 1000 01102 = -12110 X = 1010 10002 = -8710 ~X = 0101 01112 (Note: C=0 out of msb.) 1000 0110  0101 0111 1101 1101 Y - X = -121 + 87 = -34 (base 10)
  • 48. 8-bit 1’s complement addition  Ex. Let X = A816 and Y = 8616.  Calculate X - Y using 1’s complement.
  • 49. 8-bit 1’s complement addition  Ex. Let X = A816 and Y = 8616.  Calculate X - Y using 1’s complement. X = 1010 10002 = -8710 Y = 1000 01102 = -12110 ~Y = 0111 10012 (Note: C=1 out of msb.) 1010 1000 0111 1001  1 0010 0001 1  end around carry 0010 0010 X - Y = -87 + 121 = 34 (base 10)
  • 51. Binary arithmetic and Excess K (biased) Method: Simply add and then flip the sign bit. -1 0111 +5 1101 -- ---- +4 0100 -> flip sign -> 1100 +1 1001 -5 0011 -- ---- -4 1100 -> flip sign -> 0100 +1 1001 +5 1101 -- ---- +6 0110 -> flip sign -> 1110 -1 0111 -5 0011 -- ---- -6 1010 -> toggle sign -> 0010  N  N 0 1000 1000 1 1001 0111 2 1010 0110 3 1011 0101 4 1100 0100 5 1101 0011 6 1110 0010 7 1111 0001 (Not used for integer arithmetic but employed in IEEE 754 floating point standard.)