Binary -ve and +ve numbers!.

Slides:



Advertisements
Similar presentations
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Advertisements

Representations Example: Numbers –145 –CVL – –91 –
Signed Numbers.
Mathematics with Binary. Question  Below is a binary string  Which is the least significant bit (LSB)?  Which is the most significant bit (MSB)? 0.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Signed Numbers CS208. Signed Numbers Until now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers.
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Binary Representation and Computer Arithmetic
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
A-Level Computing Data representation. Objectives Know how data can be represented in a computer system Understand the need for various forms of representation.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 29, 2004 Lecture Number: 26.
Calculating Two’s Complement. The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Number Representation
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 8, 2004 Lecture Number: 7.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Computer Organization 1 Data Representation Negative Integers.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Two’s Complement The language of machines, part II.
Starter Using the mini whiteboards record your answers: 1) Name 2 different Character Sets 2) Convert the Hex number 9E into denary 3) Convert the binary.
Software Design and Development Storing Data Computing Science.
Starter Using two’s Complement form convert the following from Denary to Binary using 8 bits. Answer on mini whiteboard Using two’s.
973cs111_add_posneg.ppt Integers Whole numbers Do NOT contain decimal points (as in money) 43,689 is an integer 43, is NOT an integer (it is floating.
Representing Positive and Negative Numbers
Lesson Objectives Aims You should know about: Binary numbers ‘n’ that.
Department of Computer Science Georgia State University
Topic: Binary Encoding – Part 2
Cosc 2150: Computer Organization
Design of Digital Circuits Reading: Binary Numbers
Computer Architecture & Operations I
Addition and Subtraction
CHAPTER 9 COMPUTER ARITHMETIC - ALU
Negative Binary Numbers
2's Complement Arithmetic
Recap Add these numbers together in binary
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Computer Science 210 Computer Organization
Numbers in a Computer Unsigned integers Signed magnitude
Binary Arithmetic Binary arithmetic is essential in all digital computers and in many other types of digital systems. Addition, Subtraction, Multiplication,
Negative Binary Numbers
Lesson objectives Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement)
Number Systems.
Binary Addition & Subtraction
Computer Science 210 Computer Organization
Teaching Computing to GCSE
Topic 3: Data Signed Binary.
Data Representation in Computer Systems
2’s Complement Arithmetic
Digital Logic & Design Lecture 02.
Teaching Computing to GCSE
Unit 18: Computational Thinking
COMS 161 Introduction to Computing
Number Representation
Storing Negative Integers
Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
How are negative and rational numbers represented on the computer?
Binary to Decimal Conversion
CSC 220: Computer Organization Signed Number Representation
Binary Numbers Material on Data Representation can be found in Chapter 2 of Computer Architecture (Nicholas Carter) CSIT 301 (Blum)
Negative Bit Representation Outline
GCSE COMPUTER SCIENCE Topic 3 - Data 3.2 Signed Integers.
GCSE COMPUTER SCIENCE Topic 3 - Data 3.3 Logical and Arithmetic Shifts.
OBJECTIVES After reading this chapter, the reader should be able to :
Two’s Complement & Binary Arithmetic
Presentation transcript:

Binary -ve and +ve numbers!

Objectives 3.1.2 Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement) real numbers] 3.1.3 Be able to convert between binary and denary whole numbers (0-255) and vice versa

Recap How do you convert positive denary numbers into positive binary numbers? 32 75 123 128 64 32 16 8 4 2 1 0100100

You have to learn 2 ways… There are a number of ways of representing negative numbers in binary. You need to know Sign and magnitude Two’s Compliment.

Sign and Magnitude When working with positive, and especially negative denary numbers you will see two things. - 12 Magnitude! Sign! Don’t forget the number 32 is actually +32 We use our intelligence to recognise there should be a + sign even if there isn’t!

sign and magnitude representation In this approach, the problem of representing a number's sign can be to allocate one sign bit to represent the sign: Setting that bit (often the most significant bit) to 0 is for a positive number or positive zero, and setting it to 1 is for a negative number or negative zero.

Watch teacher demonstration Are we wasting bits? Hence, in a byte with only seven bits (apart from the sign bit), The magnitude can range from 0000000 (0) to 1111111 (127). Thus numbers ranging from −12710 to +12710 can represented once the sign bit (the eighth bit) is added. Watch teacher demonstration

Another problem… A consequence of this representation is that there are two ways to represent zero, 00000000 (0) and 10000000 (−0).

Signed and Unsigned Unsigned 1100 Signed 0 1100 0 = a positive number 1 = a negative number 11000100 = 10000001 = 00011110 = 10011111 = -68 -1 62 -31

Two’s Complement To understand how this might work, imagine a brand new car with it’s odometer set to 0000 If you drive forward 1 mile it would be come 0001 What if you could reverse for 1 mile? It would say 9999

An Example 3 00000011 2 00000010 1 00000001 00000000 -1 11111111 -2 11111110 -3 11111101

Two's complement. The problems of multiple representations of 0 are circumvented by a system called two's complement. In two's complement, negative numbers are represented by the bit pattern which is one greater (in an unsigned sense) than the ones' complement of the positive value.

Converting a number. In two's-complement, there is only one zero, represented as 00000000. Negating a number (whether negative or positive) is done by inverting all the bits and then adding 1 to that result.

Two’s Compliment -30 Step 1) Start off with the positive number 0001 1110 Step 2) Invert the bits 1110 0001 Step 3) You need to add one to the final number 1110 0010

Plenary What are the 2 methods for representing negative numbers? What number is the following 10011? What is two’s complement? Why is two’s complement needed?