Recitation2: CS 3843 Computer Organization Second week

Slides:



Advertisements
Similar presentations
CDA 3100 Recitation Week 10.
Advertisements

Sample Test 1 Question. A pattern of binary digits can be interpreted in several different ways. Show how the pattern translates using each of.
Integers. Integer Storage Since Binary consists only of 0s and 1s, we can’t use a negative sign ( - ) for integers. Instead, the Most Significant Bit.
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.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
Exercise 2.5 If each number is represented with 5 bits, 7 = in all three systems -7 = (1's complement) = (signed magnitude) = (2's.
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.
Introduction to Number Systems
Binary Number Systems.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
Simple Data Type Representation and conversion of numbers
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Negative and Floating Point.
Computer Science 111 Fundamentals of Programming I Number Systems.
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
Computer Architecture
Binary Arithmetic & Data representation
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
The Teacher CP4 Binary and all that… CP4 Revision.
Introduction to Computing Dr. Nadeem A Khan. Lecture 10.
Positional Number Systems
Number System. Number Systems Important Number systems – Decimal – Binary – Hexadecimal.
Number Representation
The Teacher CP4 Binary and all that… CP4 Revision.
Integer & Floating Point Representations CDA 3101 Discussion Session 05.
CS 101 – Aug. 31 Interpreting binary  decimal √ Decimal  binary Shorthand ways of expressing binary –Octal –“Hex” Negative numbers.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.6 Instructor: Lin Chen Sept 2013.
CEC 220 Digital Circuit Design Binary Codes
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Negative Integer Representation.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
CEC 220 Digital Circuit Design Binary Codes Mon, Aug 31 CEC 220 Digital Circuit Design Slide 1 of 14.
Computer Organization 1 Data Representation Negative Integers.
Number Representation 1 Lecture 2. Outcomes By the end of the session you should: – Understand what bits/bytes/words are. – Understanding conversion between.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
11001 / 101, / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the result.
Number Systems Decimal Can you write 12,045 in expanded form? Base? Allowable digits for each place?
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Lecture 6. Fixed and Floating Point Numbers
Recitation3: CS 3843 Computer Organization 4th week
CSE 220 – C Programming Bitwise Operators.
Negative Numbers and Subtraction
Introduction to Computing
Number Representation
Introduction To Computer Science
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.
Microprocessor Systems Design I
Computer Science 210 Computer Organization
CSE 102 Introduction to Computer Engineering
CS1010 Programming Methodology
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 6
Computer Science 210 Computer Organization
Number Representations
Data Representation Data Types Complements Fixed Point Representation
Negative Integer Representation
Fundamentals of Programming I Number Systems
Data Representation in Computer Systems
Subtraction The arithmetic we did so far was limited to unsigned (positive) integers. Today we’ll consider negative numbers and subtraction. The main problem.
How are negative and rational numbers represented on the computer?
Lecture 2: Number Systems
Chapter3 Fixed Point Representation
Number Representations
Digital Logic Design.
Presentation transcript:

Recitation2: CS 3843 Computer Organization Second week Instructor: Dr. Vijayalakshmi Saravanan TA: Tianyi Liu liuty10@gmail.ocm

Since 83 is positive & smaller than 127, Recitation2: 12 problems Problem1: 1. Using an 8-bit word, find the binary representation of 83 in 1. two's complement 2. ones' complement 3. sign-magnitude 4. as an unsigned 8-bit integer 83 = 5*16+3 = 0x53 = (0101 0011)b Since 83 is positive & smaller than 127, All the answers will be (0101 0011)b

-83 = -(5*16+3)=>1 101 0011 =>1 010 1100 =>1 010 1101 Recitation2: 12 problems Problem2: Using an 8-bit word, find the binary representation of -83 in 1. two's complement 2. ones' complement 3. sign-magnitude -83 = -(5*16+3)=>1 101 0011 Sign-magnitude =>1 010 1100 Ones’ complement =>1 010 1101 Two’s complement

Recitation2: 12 problems Problem3: Using a 16-bit word, find the binary representation of -83 in 1. two's complement 2. ones' complement 3. sign-magnitude -83 = -(5*16+3)=>1 000 0000 0101 0011 Sign-magnitude =>1 111 1111 1010 1100 Ones’ complement =>1 111 1111 1010 1101 Two’s complement

Recitation2: 12 problems Problem4: Convert each of the 10 values in problems 1-3 to two or four hexadecimal digits. Problem 1: [0101 0011] = 0x53 Problem 2: [1010 1101] = 0xad, [1010 1100] = 0xac, [1101 0011] = 0xd3 Problem 3: [1111 1111 1010 1101] = 0xffad, [1111 1111 10101 100] = 0xffac, [1000 0000 0101 0011] = 0x8053

Recitation2: 12 problems First, largest signed value must be positive Problem5: For w=7, what are the largest and smallest signed values? Problem6: For w=7, what are the largest and smallest unsigned values? First, largest signed value must be positive Second, the rest must be large enough First, largest unsigned value must be large enough smallest is 0. Sign-magnitude 1 1 1 1 1 1 Largest: 1 1 1 1 1 1 1 Ones’ complement 1 1 1 1 1 1 Smallest: Two’s complement 1 1 1 1 1 1 =3*16+15=63 Third, -0 stands for the smallest value, that is -64

Recitation2: 12 problems Problem7: 7*16+3=115 Assume w = 7, and convert -13 to unsigned. This means: represent -13 in 7-bit two's complement and then interpret the bit pattern as an unsigned integer. Express the result in decimal. First, what is -13 looks like in memory? Sign-magnitude 1 1 1 1 Ones’ complement 1 1 1 1 Two’s complement Treat it as an unsigned number 1 1 1 1 1 7*16+3=115

Recitation2: 12 problems Problem8:Assume w = 7, and convert unsigned 53 to signed. Problem9: Assume w = 7, and convert unsigned 103 to signed. 53=16*3+5 103=16*6+7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Treat it as two’s complement Then, what’s it in decimal? 1 1 1 1 1 1 1 1 No-Change - 25

1. What is 357 looks like in memory? I mean two’s complement. Recitation2: 12 problems 0 01 0110 0101 Problem10: Assume that a short is represented by 7 bits and an int is represented by 11 bits. What is the output generated by the following code segment: int x = 357; int y = -357; short sx = (short)x; short sy = (short)y; printf("%d %d %d %d\n",x, y, (int)sx, (int)sy); printf("%x %x %x %x\n",x, y, (int)sx, (int)sy); printf("%u %u %u %u\n",x, y, (int)sx, (int)sy); 2. How about -357? 1 10 1001 1011 3. What is short sx ? 110 0101 4. What is short sy ? 001 1011 5. (int)sx, int(sy) means extend sx and sy to 11 bits. So, as signed value, we should extend the signal bit. (int)sy=000 0001 1011 (int)sx=111 1110 0101

Recitation2: 12 problems x=0 01 0110 0101 y=1 10 1001 1011 1. What we have now? Recitation2: 12 problems x=0 01 0110 0101 Problem10: Assume that a short is represented by 7 bits and an int is represented by 11 bits. What is the output generated by the following code segment: int x = 357; int y = -357; short sx = (short)x; short sy = (short)y; printf("%d %d %d %d\n",x, y, (int)sx, (int)sy); printf("%x %x %x %x\n",x, y, (int)sx, (int)sy); printf("%u %u %u %u\n",x, y, (int)sx, (int)sy); y=1 10 1001 1011 (int)sx =1 11 1110 0101 (int)sy =0 00 0001 1011 2. %d: output the value in decimal x=357, y=-357, (int)sx=(1 00 0001 1011)s-m=-27 3. %x: output the value in hexadecimal x=0x165, y=0x69b, (int)sx=0x7e5, (int)sy=0x01b 4. %u: output the value in unsigned int format x=357, y=1691, (int)sx=2021, (int)sy=27

Recitation2: 12 problems Problem11: Perform the following addition in binary without converting to another base. You must show the carries.

Recitation2: 12 problems Problem12: Perform the following addition in hexadecimal without converting to another base. You must show the carries.