Solution for Homework 2



Similar documents
HOMEWORK # 2 SOLUTIO

Computer Science 281 Binary and Hexadecimal Review

Lecture 2. Binary and Hexadecimal Numbers

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

Number Representation

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

The string of digits in the binary number system represents the quantity

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Binary Numbers. Binary Octal Hexadecimal

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

CSI 333 Lecture 1 Number Systems

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Number and codes in digital systems

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

Systems I: Computer Organization and Architecture

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

2011, The McGraw-Hill Companies, Inc. Chapter 3

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Data Storage 3.1. Foundations of Computer Science Cengage Learning

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Lecture 11: Number Systems

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

CHAPTER 5 Round-off errors

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Chapter 1: Digital Systems and Binary Numbers

NUMBER SYSTEMS. 1.1 Introduction

Binary Representation

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Lecture 8: Binary Multiplication & Division

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

Section 1.4 Place Value Systems of Numeration in Other Bases

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

Numbering Systems. InThisAppendix...

NUMBER SYSTEMS. William Stallings

Chapter 4: Computer Codes

Base Conversion written by Cathy Saxton

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Number of bits needed to address hosts 8

Number Systems and Radix Conversion

THE BINARY NUMBER SYSTEM

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

The Answer to the 14 Most Frequently Asked Modbus Questions

Cyber Security Workshop Encryption Reference Manual

Binary, Hexadecimal, Octal, and BCD Numbers

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

First Bytes Programming Lab 2

MACHINE INSTRUCTIONS AND PROGRAMS

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

Useful Number Systems

Verilog - Representation of Number Literals

CPEN Digital Logic Design Binary Systems

The programming language C. sws1 1

Classless Subnetting Explained

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Informatica e Sistemi in Tempo Reale

Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:

Subnetting Examples. There are three types of subnetting examples I will show in this document:

DNA Data and Program Representation. Alexandre David

Binary Numbering Systems

Hexadecimal Object File Format Specification

Chapter 2. Binary Values and Number Systems

Decimal Number (base 10) Binary Number (base 2)

3. Convert a number from one number system to another

Intel Hexadecimal Object File Format Specification Revision A, 1/6/88

Chapter 2: Elements of Java

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Counting in base 10, 2 and 16

Lecture 4: Binary. CS442: Great Insights in Computer Science Michael L. Littman, Spring I-Before-E, Continued

Decimal to Binary Conversion

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Chapter 2: Basics on computers and digital information coding. A.A Information Technology and Arts Organizations

Advanced Tutorials. Numeric Data In SAS : Guidelines for Storage and Display Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD

Chapter 4 Register Transfer and Microoperations. Section 4.1 Register Transfer Language

Sistemas Digitais I LESI - 2º ano

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

COMBINATIONAL CIRCUITS

ASCII Characters. 146 CHAPTER 3 Information Representation. The sign bit is 1, so the number is negative. Converting to decimal gives

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

FTP client Selection and Programming

PROBLEMS (Cap. 4 - Istruzioni macchina)

Chapter 5. Binary, octal and hexadecimal numbers

CPU Organization and Assembly Language

Activity 6.7.4: IPv4 Address Subnetting Part 2

Two's Complement Adder/Subtractor Lab L03

DATA_TYPE Values and Data File Storage Formats

2.3 IPv4 Address Subnetting Part 2

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

Tamper protection with Bankgirot HMAC Technical Specification

BINARY CODED DECIMAL: B.C.D.

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Positional Numbering System

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

Transcription:

Solution for Homework 2 Problem 1 a. What is the minimum number of bits that are required to uniquely represent the characters of English alphabet? (Consider upper case characters alone) The number of unique bit patterns using i bits is 2 i. We need at least 26 unique bit patterns. The cleanest approach is to compute log 2 26 and take the ceiling (round up). This yields 5 as the answer. Trial and error is also an acceptable solution. b. How many more characters can be uniquely represented without requiring additional bits? Problem 2 With 5 bits, we can represent up to 32 (2 5 ) unique bit patterns; we can represent 32-26 = 6 more characters without requiring additional bits. Using 7 bits to represent each number, write the representations of 23 and -23 in signed magnitude and 2's complement integers Problem 3 Signed Magnitude 1's Complement 2's Complement 23 0010111 0010111 0010111-23 1010111 1101000 1101001 a. What is the largest positive number one can represent in a 12-bit 2's complement code? Write your result in binary and decimal. In Binary: 011111111111 In Decimal: 2047 (Obtained by converting 011111111111 to decimal) (1024+ 512+ 256+ 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1) b. What is the greatest magnitude negative number one can represent in a 12-bit 2's complement code? Write your result in binary and decimal. In Binary: 100000000000 In Decimal: -2048 (Obtained by converting 100000000000 to decimal) - (Not (100000000000) + 1) = -(011111111111 + 1) = -2048

c. What is the largest positive number one can represent in n-bit 2's complement code? 2 n-1-1 d. What is the greatest magnitude negative number one can represent in n-bit 2's complement code? -2 n-1 Problem 4 What are the 8-bit patterns used to represent each of the characters in the string "CS/ECE 252"? (Only represent the characters between the quotation marks.) Note: There is space between ECE and 252. From the ASCII Table, Character Hexadecimal Equivalent Binary Equivalent C 0x43 01000011 S 0x53 01010011 / 0x 2F 00101111 E 0x45 01000101 C 0x43 01000011 E 0x45 01000101 sp 0x20 00100000 2 0x32 00110010 5 0x35 00110101 2 0x32 00110010 Hence the string CS/ECE 252 is represented as 0100001101010011001011110100010101000011 0100010100100000001100100011010100110010

Problem 5 Convert the following 2's complement binary numbers to decimal. a. 0110 (0*8 + 1*4 + 1*2 + 0*1) = 6 b. 1101 - [NOT (1101) + 1] = - (0010 +1) = -3 c. 01101111 [0*128 + 1*64 + 1*32 + 0*16 + 1*8 + 1*4 + 1*2 + 1*1] = 111 d. 1101101100011100 - [NOT (1101101100011100) + 1] = - (0010010011100011 + 1) = -9444 Problem 6 Express the negative value -22 as a 2's complement integer, using eight bits. Repeat it for 16 bits and 32 bits. What does this illustrate with respect to the properties of sign extension as they pertain to 2's complement representation? 8 bit The 8-bit binary representation of 22 is 00010110. So, -22 in 2 s complement form is (NOT (00010110) + 1) = (11101001 + 1) = 11101010 16 bit The 16-bit binary representation of 22 is 00000000 00010110. So, -22 in 2 s complement form is (NOT (00000000 00010110) + 1) = (11111111 11101001 + 1) = 11111111 11101010 32 bit The 8-bit binary representation of 22 is 00000000 00000000 00000000 00010110. So, -22 in 2 s complement form is (NOT (00000000 00000000 00000000 00010110) + 1) = (11111111 11111111 11111111 11101001 + 1) = 11111111 11111111 11111111 11101010 The pattern that we see is that when we increase the number of bits in the 2's complement representation, we sign extend, meaning that we take the leftmost bit of the original representation and duplicate it into the added bits of the new representation.

Problem 7 Write the decimal equivalents for these IEEE floating point numbers. a. 0 01111111 00000000000000000000000 (-1)*0 * 1.0*2 127-127 = (1.0) 2 = (1) 10 b. 1 01111110 10000000000000000000000 (-1)*1 * 1.1*2 126-127 = (-0.11) 2 = (-0.75) 10 Problem 8 Describe what conditions indicate overflow has occurred when two 2's complement numbers are added. When adding two numbers, overflow occurs when the two operands have the same leftmost bit and the leftmost bit of the answer is different. When the operands have differing leftmost bits, overflow cannot occur when adding them together because we are adding a positive number with a negative number which means we are actually subtracting. It implies that the result cannot be bigger than the operands. So there is no possibility of overflow in this case. The leftmost bit is frequently referred to as the Most Significant Bit (MSB for short). Problem 9 De Morgan s Laws: i. NOT (P AND Q) = (NOT P) OR (NOT Q) ii. NOT (P OR Q) = (NOT P) AND (NOT Q) Verify these for P = 1011 and Q = 1101 NOT (P) = NOT (1011) = 0100 NOT (Q) = NOT (1101) = 0010 i. (NOT P) OR (NOT Q) = 0110 NOT (1011 AND 1101) = NOT (1001) = 0110 NOT (P AND Q) = (NOT P) OR (NOT Q)

ii. NOT (P OR Q) = NOT (1011 OR 1101) = NOT (11110 = 0000 NOT (P) AND NOT (Q) = 0100 AND 0010 = 0000 NOT (P OR Q) = (NOT P) AND (NOT Q) Problem 10 The following binary numbers are 4-bit 2's complement binary numbers. Which of the following operations generate overflow? Justify your answers by translating the operands and results into decimal. a. 0011 + 1100 3 + -[NOT(1100)+1] = 3 (0011+1) 2 = (3-4) 10 = -1 10 0011 + 1100 = (1111) 2 = -[NOT(1111)+1] = -1 10 (No Overflow) b. 0111 + 1111 7 + -[NOT(1111)+1] = 7-1 = 6 10 0111 + 1111 = (0110) 2 = 6 10 (No Overflow) c. 1110 + 1000 -[NOT(1110) + 1] [NOT(1000) + 1] = -(10) 2 (1000) 2 = -2 + - 8 = -10 1110 + 1000 = 0110 = 6 10 (Overflow!) d. 0110 + 0010 6 + 2 = 8 1 000 = - [ NOT(1000) + 1] = -(0111+1) = -(1000) = -8 (Overflow)