The document discusses various methods for representing signed integers in binary, including signed magnitude, 1's complement, 2's complement, and excess binary. It provides examples of adding, subtracting, and multiplying numbers in binary using these different representations. 2's complement is described as the most common method used today due to its simplicity. The key aspects of 2's complement include representing negative numbers by flipping all bits and adding 1, and performing subtraction by adding the 2's complement. Overflow conditions for addition are also explained.
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Ra'Fat Al-Msie'deen
Logic Circuits Design: This material is based on chapter 1 of “Logic and Computer Design Fundamentals” by M. Morris Mano, Charles R. Kime and Tom Martin
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Ra'Fat Al-Msie'deen
Logic Circuits Design: This material is based on chapter 1 of “Logic and Computer Design Fundamentals” by M. Morris Mano, Charles R. Kime and Tom Martin
A power point presentation on number system which briefly explains the conversion of decimal to binary, binary to decimal, binary to octal, octal to decimal. Ping me at Twitter (https://twitter.com/rishabh_kanth), to Download this Presentation.
Computers only deal with binary data (0s and 1s), hence all data manipulated by computers must be represented in binary format.
Machine instructions manipulate many different forms of data:
Numbers:
Integers: 33, +128, -2827
Real numbers: 1.33, +9.55609, -6.76E12, +4.33E-03
Alphanumeric characters (letters, numbers, signs, control characters): examples: A, a, c, 1 ,3, ", +, Ctrl, Shift, etc.
So in general we have two major data types that need to be represented in computers; numbers and characters
Introduction
Numbering Systems
Binary & Hexadecimal Numbers
Binary and Hexadecimal Addition
Binary and Hexadecimal subtraction
Base Conversions
A power point presentation on number system which briefly explains the conversion of decimal to binary, binary to decimal, binary to octal, octal to decimal. Ping me at Twitter (https://twitter.com/rishabh_kanth), to Download this Presentation.
Computers only deal with binary data (0s and 1s), hence all data manipulated by computers must be represented in binary format.
Machine instructions manipulate many different forms of data:
Numbers:
Integers: 33, +128, -2827
Real numbers: 1.33, +9.55609, -6.76E12, +4.33E-03
Alphanumeric characters (letters, numbers, signs, control characters): examples: A, a, c, 1 ,3, ", +, Ctrl, Shift, etc.
So in general we have two major data types that need to be represented in computers; numbers and characters
Introduction
Numbering Systems
Binary & Hexadecimal Numbers
Binary and Hexadecimal Addition
Binary and Hexadecimal subtraction
Base Conversions
Reviewing number systems involves understanding various ways in which numbers can be represented and manipulated. Here's a brief overview of different number systems:
Decimal System (Base-10):
This is the most common number system used by humans.
It uses 10 digits (0-9) to represent numbers.
Each digit's position represents a power of 10.
For example, the number 245 in decimal represents (2 * 10^2) + (4 * 10^1) + (5 * 10^0).
Binary System (Base-2):
Used internally by almost all modern computers.
It uses only two digits: 0 and 1.
Each digit's position represents a power of 2.
For example, the binary number 1011 represents (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (1 * 2^0) in decimal, which equals 11.
Octal System (Base-8):
Less commonly used, but still relevant in some computer programming contexts.
It uses eight digits: 0 to 7.
Each digit's position represents a power of 8.
For example, the octal number 34 represents (3 * 8^1) + (4 * 8^0) in decimal, which equals 28.
Hexadecimal System (Base-16):
Widely used in computer science and programming.
It uses sixteen digits: 0 to 9 followed by A to F (representing 10 to 15).
Each digit's position represents a power of 16.
Often used to represent memory addresses and binary data more compactly.
For example, the hexadecimal number 2F represents (2 * 16^1) + (15 * 16^0) in decimal, which equals 47.
Each number system has its own advantages and applications. Decimal is intuitive for human comprehension, binary is fundamental in computing due to its simplicity for electronic systems, octal and hexadecimal are often used for human-readable representations of binary data in programming, particularly when dealing with memory addresses and byte-oriented data.
Understanding these number systems is essential for various fields such as computer science, electrical engineering, and mathematics, as they provide different perspectives on how numbers can be represented and manipulated.
A digital system can understand positional number system only where there are only a few symbols called digits and these symbols represent different values depending on the position they occupy in the number.
CA in Patna is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Patna.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
CA in Patna is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Patna.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
CA in Dwarka is a team of professional Chartered Accountant which are providing best services like Company Registration, Income Tax Return, Sales Tax Consultants, Bank Audit and other services specially in Dwarka and Delhi NCR.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Css Founder is Website Designing Company working with the mission of Website For Everyone Website Start From 999/-* More Packages are available. we are best company in website designing company in Delhi, as we are also working in Website Designing company in Mumbai.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
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
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
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
+ n - n
0 0000 0000
1 0001 1111
2 0010 1110
3 0011 1101
4 0100 1100
5 0101 1011
6 0110 1010
In general, for k bits, the signed range is
[-2k-1..+2k-1-1].
So where does the extra negative value come
from? 8 1000
7 0111 1001
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
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.
This is -2.
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
1000 0110
+
0101 0111
(Note: C=0 out of msb.) 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)