Data Representation Integers

Slides:



Advertisements
Similar presentations
Sample Test 1 Question. A pattern of binary digits can be interpreted in several different ways. Show how the pattern translates using each of.
Advertisements

J. Michael Moore Computer Organization CSCE 110. J. Michael Moore High Level View Of A Computer ProcessorInputOutput Memory Storage.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
J. Michael Moore Computer Organization CPSC 110. J. Michael Moore High Level View Of A Computer ProcessorInputOutput Memory Storage.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
CSE20 Lecture 3 Number Systems: Negative Numbers 1.Sign and Magnitude Representation 2.1’s Complement Representation 3.2’s Complement Representation 1.
Two’s Complement 1.As an action: (Assume the starting value is 1011) 1.Flip the bits from the starting value => Add one to get the answer.
Number Systems Computer Science 210 Computer Organization.
3. Representing Integer Data
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 :
Simple Data Type Representation and conversion of numbers
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19.
ECE 331 – Digital System Design
Number systems, Operations, and Codes
Number Representation
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Cis303a_chapt03_exam1_answer.ppt CIS303A: System Architecture Exam 1: Chapter 3 Answer List the characters (digits) for the following bases. 1) Decimal:
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
11001 / 101, / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the result.
Negative Number Sign-Magnitude: left-most bit as the sign bit –16 bits –Example: 4-bit numbers is given by is given by ’s complement:
Computer Representation of Information
Data Representation COE 308 Computer Architecture
Binary & Hex Review.
Computer Science 210 Computer Organization
Design of Digital Circuits Reading: Binary Numbers
Chapter 2 Binary Number Systems.
David Kauchak CS 52 – Spring 2017
Data Representation ICS 233
Data Representation.
A brief comparison of integer and double representation
Number Representation
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
11001 / 101 , / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the.
Computer Science 210 Computer Organization
CSE 102 Introduction to Computer Engineering
Lesson objectives Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement)
Number Systems.
Addition and Substraction
Computer Science 210 Computer Organization
Number Representation
Topic 3: Data Signed Binary.
Computer Science 210 Computer Organization
Digital Electronics and Microprocessors
Unit 18: Computational Thinking
Negatives, Addition, Subtraction
Number Representation
Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
Computer Organization
2’s Complement form 1’s complement form 2’s complement form
CPS120: Introduction to Computer Science
Decimal and binary representation systems
Numbers representations
Data Representation ICS 233
Binary & Hex Review.
Activity 2 How is the word length of a two’s complement representation changed without affecting its value? In this activity, we are going to study how.
OBJECTIVES After reading this chapter, the reader should be able to :
Data Representation COE 308 Computer Architecture
Two’s Complement & Binary Arithmetic
Today Binary addition Representing negative numbers 2.
Presentation transcript:

Data Representation Integers CSCE 121 J. Michael Moore

Binary Numbers Base Ten Numbers (Integers) Binary numbers are the same characters 0 1 2 3 4 5 6 7 8 9 5401 is 5x103 + 4x102 + 0x101 + 1x100 Binary numbers are the same 0 1 1011 is 1x23 + 0x22 + 1x21 + 1x20 J. Michael Moore

Converting Binary to Base 10 23 = 8 22 = 4 21 = 2 20 = 1 10012 = ____10 = 1x23 + 0x22 + 0x21+ 1x20 = 1x8 + 0x4 + 0x2 + 1x1 = 8 + 0 + 0 + 1 = 910 01102 = ____10 (Try yourself) 01102 = 610 J. Michael Moore

Converting Base 10 to Binary 28 = 256 27 = 128 26 = 64 25 = 32 24 = 16 23 = 8 22 = 4 21 = 2 20 = 1 38810 = ____2 388 - 28 = 132 132 - 27 = 4 4 - 22 = 0 28 27 26 24 25 22 23 20 21 1 1 1 J. Michael Moore

Converting Base 10 to Binary 38810 = ____2 38810 / 2 = 19410 Remainder 0 19410 / 2 = 9710 Remainder 0 9710 / 2 = 4810 Remainder 1 4810 / 2 = 2410 Remainder 0 2410 / 2 = 1210 Remainder 0 1210 / 2 = 610 Remainder 0 610 / 2 = 310 Remainder 0 310 / 2 = 110 Remainder 1 28 27 26 24 25 22 23 20 21 110 / 2 = 010 Remainder 1 1 1 1 J. Michael Moore

Other common number representations Octal Numbers characters 0 1 2 3 4 5 6 7 8 7820 is 7x83 + 8x82 + 2x81 + 0x80 4112 (base 10) Hexadecimal Numbers 0 1 2 3 4 5 6 7 8 9 A B C D E F 2FD6 is 2x163 + Fx162 + Dx161 + 6x160 12,246 (base 10) http://www.kaagaard.dk/service/convert.htm Note: We will not ask you to do number conversions on the exam. J. Michael Moore

Negative Numbers Can we store a negative sign? What can we do? Use a bit Negative: leftmost bit set to 1 Positive: leftmost bit set to 0 Most common is two’s complement J. Michael Moore

Representing Negative Numbers Two’s Complement To convert binary number to its negative… flip all the bits change 0 to 1 and 1 to 0 add 1 if the leftmost bit is 0, the number is 0 or positive if the leftmost bit is 1, the number is negative J. Michael Moore

Two’s Complement What is -9? Addition and Subtraction are easy 9 is 00001001 in binary flip the bits → 11110110 add 1 → 11110111 Addition and Subtraction are easy always addition If it is subtraction, first take negative of number being subtracted Then add! J. Michael Moore

Two’s Complement 1 1 1 1 1 1 1 1 1 = ? Subtraction Flip bits 4 - 9 = -5 4 + (-9) = -5 (becomes addition) 00000100 + 11110111 = ? Flip bits 11111011 → 00000100 Add one → 00000101 Which is 5 Since its positive two’s complement is 5, the number is -5! 1 1 1 1 1 1 1 1 1 1 = ? Negative since it starts with a 1 J. Michael Moore

Two’s Complement 1 1 1 = 4 Subtraction 13 - 9 = 4 13 + (-9) = 4 (becomes addition) 00001101 + 11110111 = ? But that doesn’t matter since we get the correct answer anyway 1 1 1 1 1 1 1 1 1 1 This bit is lost 1 = 4 J. Michael Moore

Two’s Complement Range If we did not use two’s complement and used the left most bit to indicate negative: Negative 1111111 to positive 1111111 -127 to 127 With two’s complement -128 to 127 Gain an extra digit in the range.

Ranges of Values Integer datatypes can be positive or negative What if you don’t need negative numbers? short Max: 32,767 Min: -32,768 Unsigned!!! unsigned short Max: 65,535 Min: 0