UNIT 7A Data Representation: Numbers and Text. Digital Data

Similar documents
15110 Principles of Computing, Carnegie Mellon University - CORTINA. Digital Data

MACHINE LEVEL REPRESENTATION OF DATA

BINARY SYSTEM. Binary system is used in digital systems because it is:

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Lecture 2: Number Systems

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Announcement. (CSC-3501) Lecture 3 (22 Jan 2008) Today, 1 st homework will be uploaded at our class website. Seung-Jong Park (Jay)

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

COMP2611: Computer Organization. Data Representation

CS & IT Conversions. Magnitude 10,000 1,

Digital Fundamentals

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

LING 388: Computers and Language. Lecture 5

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Inf2C - Computer Systems Lecture 2 Data Representation

Data Representation and Binary Arithmetic. Lecture 2

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

IBM 370 Basic Data Types

CHW 261: Logic Design

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

COMP Overview of Tutorial #2

Digital Fundamentals

SISTEMI EMBEDDED. Basic Concepts about Computers. Federico Baronti Last version:

Binary. Hexadecimal BINARY CODED DECIMAL

Representing Information. Bit Juggling. - Representing information using bits - Number representations. - Some other bits - Chapters 1 and 2.3,2.

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

Signed Binary Numbers

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Lecture (02) Operations on numbering systems

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Binary Codes. Dr. Mudathir A. Fagiri

Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Numeric Encodings Prof. James L. Frankel Harvard University

The type of all data used in a C++ program must be specified

Chapter 2. Data Representation in Computer Systems

IEEE Standard for Floating-Point Arithmetic: 754

Introduction to Computer Science (I1100) Data Storage

MYcsvtu Notes DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes

CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems

Chapter 1. Digital Systems and Binary Numbers

Chapter 10 Error Detection and Correction 10.1

Digital Systems and Binary Numbers

Data Representation 1

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Chapter 3 DATA REPRESENTATION

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

BSM540 Basics of C Language

Introduction to Computers and Programming. Numeric Values

CS 121 Digital Logic Design. Chapter 1. Teacher Assistant. Hadeel Al-Ateeq

CS 31: Intro to Systems Binary Representation. Kevin Webb Swarthmore College January 27, 2015

The type of all data used in a C (or C++) program must be specified

M1 Computers and Data

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Computer Organization

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

Data Representation in Computer Memory

Chapter 2 Data Representations

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

Signed umbers. Sign/Magnitude otation

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Data Representations & Arithmetic Operations

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Number System. Introduction. Decimal Numbers

3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

Final Labs and Tutors

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Midterm Exam Review Slides

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

COMP2121: Microprocessors and Interfacing. Number Systems

CSCI 2212: Intermediate Programming / C Chapter 15

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader

UNIVERSITY OF WISCONSIN MADISON

Chapter 4: Data Representations

Number Systems. Both numbers are positive

Hexadecimal Numbers. Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those?

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

MC1601 Computer Organization

Chapter 2 Number Systems and Codes Dr. Xu

Binary Systems and Codes

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

DIGITAL SYSTEM DESIGN

Memory Addressing, Binary, and Hexadecimal Review

Chapter 10 Error Detection and Correction. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

umber Systems bit nibble byte word binary decimal

Transcription:

UNIT 7A Data Representation: Numbers and Text 1 Digital Data 10010101011110101010110101001110 What does this binary sequence represent? It could be: an integer a floating point number text encoded with ASCII or another standard a pixel of an image several digital samples of a music recording an instruction that the computer is executing... 2 1

Integer Representation An integer can be represented using binary. An integer can be: unsigned (always considered non-negative) signed (positive or negative) An integer can be represented using varying numbers of bits 8 bits (byte) 32 bits 16 bits (word) 64 bits... 3 Unsigned Integers Every bit represents a power of 2. Example (8 bits): 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 128 64 32 16 8 4 2 1 1 0 1 1 0 1 0 1 2 7 2 5 2 4 2 2 2 0 128 + 32 + 16 + 4 + 1 = 181 4 2

Unsigned Integers: Range bits minimum maximum 8 0 2 8 1 (255) 16 0 2 16 1 (65,535) 32 0 2 32 1 (4,294,967,295) 5 Signed Integers Every bit represents a power of 2 except the left-most bit, which represents the sign of the number (0 = positive, 1 = negative) Example for positive integer (8 bits): _0 + 2 6 2 5 2 4 2 3 2 2 2 1 2 0 0 0 1 1 0 1 0 0 + 2 5 2 4 2 2 32 + 16 + 4 = +52 6 3

Signed Integers: 2 s complement When the leftmost bit is a 1, the integer is negative. To find its magnitude, we take the 2 s complement of this number. The 2 s complement is obtained by flipping each bit of the number (from 0 to 1, or 1 to 0) and then adding 1 to that number. 7 Signed Integers: Negative What value is this signed integer? 1 1 0 0 1 1 0 0 - (leftmost bit 1 -> negative) Flip each bit: 0 0 1 1 0 0 1 1 and add 00000001 to get magnitude: 0 0 1 1 0 1 0 0 2 5 2 4 2 2 32 + 16 + 4 = 52 So, 11001100 = -52 8 4

Signed Integers: Negative Example: How do you store -52 in 8 bits? Start with +52: 0 0 1 1 0 1 0 0 2 5 2 4 2 2 32 + 16 + 4 = 52 Flip each bit: 1 1 0 0 1 0 1 1 and add 00000001 (in base 2): 1 1 0 0 1 1 0 0 = -52 9 2 s complement property When you add a number to its 2 s complement (in binary), you always get 0. Remember, you re using base 2 arithmetic. Example (using 8 bits): 00110100 +52 + 11001100-52 00000000 0 10 5

Signed Integers: Range bits minimum maximum 8 2 7 2 7 1 ( 128) (+127) 10000000 (binary) 01111111 (binary) 16 2 15 2 15 1 ( 32,768) (+32,767) 32 2 31 2 31 1 ( 2,147,483,648) (+2,147,483,647) 11 Text: ASCII standard ASCII (American Standard Code for Information Interchange) 7-bit code to represent standard U.S. characters on a keyboard Typically stored using 8 bits. The 8 th bit is sometimes used for parity (more on this shortly). 12 6

ASCII table Values above are represented in hexadecimal (base 16). ASCII code for M is 4D (hex). 13 ASCII Example The ASCII code for M is 4D hexadecimal. Conversion from base 16 to base 2: hex binary hex binary hex binary hex binary 0 0000 4 0100 8 1000 C 1100 1 0001 5 0101 9 1001 D 1101 2 0010 6 0110 A 1010 E 1110 3 0011 7 0111 B 1011 F 1111 4D (hex) = 01001101(binary) = 77 (decimal) (leftmost bit can be used for parity) 14 7

Parity To detect transmission errors, the 8 th (leftmost) bit could be used as an errordetection bit. Even parity: Set the leftmost bit so that the number of 1 s in the byte is even. Odd parity: Set the leftmost bit so that the number of 1 s in the byte is odd. 15 Example The character M is transmitted using odd parity. M in ASCII (7-bits) is 1001101. Using odd parity, we transmit 11001101 since this makes the number of 1 s odd. If the receiver receives a character with an even number of 1 s, the receiver knows something went wrong and requests a retransmission. If two bits are flipped during transmission, we can t detect this with this simple parity scheme, however the probability of 2 or more bits in error is extremely low. 16 8

Seven characters are transmitted here as bytes using even parity along with a special 8 th byte. The two colors represent 1 s and 0 s. One bit is in error. Can you find it? 17 Floating Point Numbers Age of the Universe in years: + 13.7X 10 9 sign significand exponent Floating point numbers are commonly represented as a binary number with these three components. 18 9

IEEE-754 standard Most common encoding of floating point numbers on computers today. 32-bit ( single-precision ) floating point: exponent significand (8 bits) (23 bits) sign (1 bit) 19 Binary Significand IEEE-754 standard Always assumes the form 1.XXXXXXXXX in binary. Does not store the leading 1. Stores the fractional part using 23 bits. Exponent Stores exponent offset by 127. Example: An exponent of -6 would be stored as 121. Stores exponent as unsigned 8-bit integer. Exponent range: min -126, max +127 20 10

Example: IEEE-754 Floating point number in binary: -1.0110111 X 2 00011010 1 10011001 01101110000000000000000 exponent significand (8 bits) (23 bits) sign 00011010 + 01111111 (1 bit) = 10011001 21 11