Chapter 1 Representing Data in a Computer

Slides:



Advertisements
Similar presentations
DAT2343 Summary of Standard Data Encoding © Alan T. Pinck / Algonquin College; 2003.
Advertisements

ICS312 Set 2 Representation of Numbers and Characters.
Lecture - 2 Number systems and computer data formats
Lecturer: Omid Jafarinezhad Sharif University of Technology Department of Computer Engineering 1 Fundamental of Programming (C) Lecture 2 Number Systems.
Chapter 2 : Number System
Chapter 5 Number Represent and Arithmetic Ciacuit 逻辑电路及其完成的算术运算 (217)
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Data Representation ICS 233
Data Representation in Computers
Chapter 02 Binary Values and Number Systems Nell Dale & John Lewis.
Number Systems and Codes Discussion D4.1. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Data Storage. SIGN AND MAGNITUDE Storing and representing numbers.
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Simple Data Type Representation and conversion of numbers
Chapter 2 Introduction to Number System & Data Formats.
Chapter 3 Number Representation. Convert a number from decimal 、 hexadecimal,octal to binary notation and vice versa. Understand the different representations.
CS105 INTRODUCTION TO COMPUTER CONCEPTS BINARY VALUES & NUMBER SYSTEMS Instructor: Cuong (Charlie) Pham.
Computers Organization & Assembly Language
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
Binary Arithmetic & Data representation
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.
ICS312 Set 1 Representation of Numbers and Characters.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
Chapter 2 Binary Values and Number Systems. 2 2 Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645,
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Chapter four – The 80x86 Instruction Set Principles of Microcomputers 2015年10月19日 2015年10月19日 2015年10月19日 2015年10月19日 2015年10月19日 2015年10月19日 1 Chapter.
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in other bases.
Chapter Two– Data Numbering & Character Encoding System in Microcomputer Principles of Microcomputers 2015年10月22日 2015年10月22日 2015年10月22日 2015年10月22日 2015年10月22日.
The Hexadecimal Number System and Memory Addressing ISAT 121.
Chapter1: Number Systems
Binary Values and Number Systems
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Chapter 2 Data Representation 天津大学软件学院.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
Data Representation, Number Systems and Base Conversions
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
SAK Chapter 21 Chapter 2 : Number System 2.1 Decimal, Binary, Octal and Hexadecimal Numbers 2.2 Relation between binary number system with other.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Chapter 2 Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
Some basic concepts underlying computer archi­tecture
Data Representation COE 308 Computer Architecture
Lec 3: Data Representation
Data Representation.
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 : INTRODUCTION
CSE 102 Introduction to Computer Engineering
Chapter 3 Data Representation
Digital Logic & Design Lecture 03.
Number Systems Lecture 2.
2’s Complement form 1’s complement form 2’s complement form
Storing Integers and Fractions
Data Representation COE 308 Computer Architecture
Presentation transcript:

Chapter 1 Representing Data in a Computer 数据在计算机中的表示 Main contents Common ways that representing data (数据)in microcomputer . number 数 character 字符

Aims Introduce common ways that representing data in computer Binary numbers(二进制数) Hexadecimal Numbers(十六进制数) ASCII codes for characters (ASCII 代码) BCD codes Calculation of Binary (二进制计算) Change between Binary and Hexadecimal(二进制和十六进制之间的转换)

Outcomes 1. Can convert among binary, decimal, and hexadecimal numbers. 2. Can differentiate(区分) and represent numeric and alphabetic information as integers, BCD, and ASCII data.

1.1 Binary and Hexadecimal Numbers Binary numbering System Hexadecimal numbering System Octal numbering System(八进制) Conversion of Integer between Binary , Hexadecimal and Decimal

Decimal Number(十进制) Being used in our life Base 10 Example: 36864=3×104+6 × 103+8 × 102+6 × 101+4 × 100

Binary Number Being used in computer Represent data in bits Binary digits , zero(0)/one(1) Base 2 Example: 1101b=1*23+1*22+0*21+1*20

Conversion between Binary Number and Decimal Number Convert from Decimal To Binary Divide DecimalNumber by 2(base of Binary),getting Quotient(商) and Remainder(余数) Remainder is the next digit(right to left); Example:5876 Convert from Binary to Decimal Multiply each bit by powers of 2 Example:1101110101b

Hexadecimal Number Binary Number is difficult to be read and write Hexadecimal Number is a convenient representation of binary numbers Base 16 0~9 ,A,B,C,D,E,F Example:3B8E2H

Conversion between Hexadecimal Number and Decimal Number Convert from Decimal To Hexadecimal Example:5876 Divide DecimalNumber by 16(base of hexadecimal), getting Quotient and Remainder Remainder is the next digit(right to left); Convert from hexadecimal to Decimal Example:8EFh Multiply each bit by powers of 16

Conversion between Hexadecimal Number and Binary Number Convert from Hexadecimal To Binary Substitute four bits for each hex digit Pading with leading zeros as needed E.g. 8EFh Convert from Binary to Hexadecimal From the right, breaking the binary number into groups of four bits Substitute the corresponding hex digit for each group of four bits E.g. 100b

Octal Number(八进制) Base 8 0~7 Example:123O

Conversion between binary and Octal Convert from Octal To Binary Substitute three bits for each octal digit Pading with leading zeros as needed E.g. 123o Convert from Binary to Octal From the right, breaking the binary number into groups of three bits Substitute the corresponding octal digit for each group of three bits E.g. 1011011b

1.2 Character Codes Character---Letters, numeral, punctuation marks and so on Assigning a numeric value to each character American Standard Code for Information Interchange(ASCII) is commonly used

ASCII Seven bits to represent characters, so 128 different characters can be represented using ASCII codes. Printable characters: 20h~7eh A~Z 41h~5ah a~z 61h~7ah 0~9 30h~39h Control characters:00h~1fh ESC 1bh , 0dh carriage return(CR,回车), 0AH line feed(LF,换行)

Computer Data Formats: BCD BCD digit 0000 ~ 1001 binary ( 00002 ~ 10012) 0 ~ 9 decimal Two forms Packed BCD (压缩): two digits per byte Unpacked BCD (非压缩): one digit per byte Decimal packed BCD unpacked BCD Hex 12 0001 0010 0000 0001 0000 0010 0CH 96 1001 0110 0000 1001 0000 0110 60H 96H 0906H

1.3 2‘s Complement Representation for Signed Integers To form a two’s complement Method one: Invert each bit of a number from 0 to 1 or from 1 to 0, then add a 1 Method two: Subtract the number by 0 +8 = 00001000 11110111 + 1 -8 = 11111000 0 =100000000 -(8= 00001000) -8 = 11111000

Byte-Sized Data One byte, 8 bits, 00H~FFH Unsigned integer (无符号整数): 0 ~ 255 signed integer (有符号整数): -128 ~ 0 ~ +127 Negative signed numbers are stored in the two’s complement form (补码) To store 8-bit data, use DB directive

Word-Sized Data Two bytes, 16 bits, 0000H~FFFFH Unsigned integer : 0 ~ 65,535 ( 216-1) signed integer : -32,768 ~ 0 ~ +32767 13400 = 3458H, 0 - 3458H = CBA8H So, -13400 = CBA8H in two’s complement Please note -1 = FFFFH (word-sized ) in two’s complement -1 = FFH (byte-sized ) in two’s complement

Data type (数据类型) Byte: 8bits Word:16bits Doubleword:32bits Quaword:64bits

1.4 Addition and subtraction of 2’s complement numbers Discusses addition(加法) and subtraction(减法) of 2’s complement numbers Introduces the concepts of carry (进位)and overflow(溢出)

Addition of hex numbers 2567 + 467 3034 0 A 0 7 + 0 1 D 3 0 B D A 7+3=10=A 0+D=0+13=13=D A+1=10+1=11=B 0+0=B BDAh=3034d

Addition of hex numbers signed number: 518+(-80)=438 unsigned number: 518+65456=65974 0206 + FFB0 101B6 0+6=6 carry 0+B=0+12=12=B 2+F=2+15=17=1+16(carry) 0+F+1(carry)=16=1+16(carry) 101B6h=65974(can’t be represented in a word) 01B6h=438

Addition of hex numbers signed number: (-25)+(-10)=-35 unsigned number: 65511+65526=131037 FFE7 + FFF6 1FFDD 7+6=13=D carry E+F=14+15=29=16 (carry) +13=D F+F=15+15+1 (carry) =31=15+16(carry)=F F+F+1(carry)=31=15+16(carry)=F 1FFDDh=131037(can’t be represented in a word) FFDDh=-35

Addition of hex numbers AC99 18495+25690=44185 OVERFLOW signed number: AC99H=-21351 unsigned number: AC99h=44185

Addition of hex numbers E9FF + 8CF0 176EF carry signed number: (-5633)+(-29456)=-35089 unsigned number: 59903+36080=95983 76EFH=30447 OVERFLOW

CARRY AND OVERFLOW Carry into sign bit? Carry out of sign bit? no yes

Examples: 0A07+01D3=? 0206+FFB0=? FFE7+FFF6=? 483F+645A=? E9FF+8CF0=?

Subtraction of hex numbers In a computer, subtraction a-b of numbers a and b is usually performed by taking the 2’s complement of b and adding the result to a. That means adding the negation of b.

BORROW 0 0 C 3 - 0 2 6 A 0 0 C 3 + F D 9 6 F E 5 9 195-618=-423 FE59H=-423 If there is no carry in the addition, then there is a borrow in the subtraction.

NO BORROW 0 3 D 9 - 0 1 9 B 0 3 D 9 + F E 6 5 1 0 2 3 E 985-411=574 023EH=574 If there is a carry in the addition, then there is no borrow in the subtraction.

-29123-15447=- 44570 (outside the range) OVERFLOW 8 E 3 D - 3 C 5 7 8 E 3 D + C 3 A 9 1 5 1 E 6 -29123-15447=- 44570 (outside the range) If overflow occurs in the addition, then it occurs in the original subtraction problem;if it does not occur in the addition, then it does not occur in the original subtraction.

QUESTION Can you summarize another regulation of carry or overflow occurring?

1.5 Other Systems for Representing Numbers 1‘s complement(反码) Binary Coded Decimal BCD Floating point

Computerese Computerese, Computer terminology 计算机专业术语 Terms and jargon used in the computer field Technical terms For example, He spoke such a jargon, I couldn’t make head or tail of what he said. Return

Computerese-1 Numeric a. 数字的 Alphabetic a. 字母的 Alphanumeric a.字母数字的 Data type 数据类型 integer 整数,floating-point 浮点数 BCD (Binary-coded decimal) 二进制编码的十进制 ASCII (American Standard Code for Information Interchange) 美国信息交换标准代码

Computerese-2 bit (binary digit) 二进制位,比特 Byte = 8 bits 字节 Word = 2 bytes (16-bit) 字 Double word = 2 words (32-bit) 双字 Quad word = 4 words (64-bit) 4字 Binary 二进制的 Decimal 十进制的 Hexadecimal 十六进制的

Questions and problems: P6. Exercise1.1 2, 4, 5, 8, 9, 14, 15 P8. Exercise1.2 1(a),2(c), 3(e) P14. Exercise1.3 1(a)(e),2(a)(c), 3(b)(d),4(c) (d), 5(c) (a) , 6(a)(7), 7, 8 P20. Exercise1.4 1,3,5,7,9,11,13,12,14