Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.

Slides:



Advertisements
Similar presentations
Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
Advertisements

DAT2343 Summary of Standard Data Encoding © Alan T. Pinck / Algonquin College; 2003.
ICS312 Set 2 Representation of Numbers and Characters.
The Binary Numbering Systems
Lecture - 2 Number systems and computer data formats
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
A digital system is a system that manipulates discrete elements of information represented internally in binary form. Digital computers –general purposes.
CHAPTER 2 Number Systems, Operations, and Codes
1 CSE1301 Computer Programming Lecture 29: Number Representation (Part 1)
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Data Representation Computer Organization &
Data Representation COE 205
1 CSE1301 Computer Programming Lecture 28 Number Representation (Integer)
Data Representation ICS 233
Digital Fundamentals Floyd Chapter 2 Tenth Edition
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
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.
Computer Architecture
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
Binary Arithmetic & Data representation
Data Representation and Computer Arithmetic
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
ICS312 Set 1 Representation of Numbers and Characters.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Number systems & Binary codes MODULE 1 Digital Logic Design Ch1-2 Outline of Chapter 1  1.1 Digital Systems  1.2 Binary Numbers  1.3 Number-base Conversions.
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,
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.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Data Representation, Number Systems and Base Conversions
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Number Systems Denary Base 10 Binary Base 2 Hexadecimal Base 16
Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
Dr. ClincyLecture 2 Slide 1 CS Chapter 2 (1 of 5) Dr. Clincy Professor of CS Note: Do not study chapter 2’s appendix (the topics will be covered.
Computer Representation of Information
Floating Point Representations
Some basic concepts underlying computer archi­tecture
Data Representation COE 308 Computer Architecture
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
3.1 Denary, Binary and Hexadecimal Number Systems
Data Representation Binary Numbers Binary Addition
Standard Data Encoding
Data Representation COE 301 Computer Organization
Data Representation ICS 233
Chapter3 Fixed Point Representation
Data Representation COE 308 Computer Architecture
Presentation transcript:

Chapter 1 Representing Data in a Computer

1.1 Binary and Hexadecimal Numbers

Decimal Numbers Base = 3 x x x x s 10s 100s 1000s

Binary Numbers Base 2, using bits (binary digits) 0 and = 1 x x x x x 2 4 1s 2s 4s 8s 16s = 23 10

Hexadecimal Numbers Base 16 Digits –0-9 same as decimal –A for 10 –B for 11 –C for 12 –D for 13 –E for 14 –F for 15

Hexadecimal to Decimal Base 16 5CB = 11 x x x s 16s 256s 5CB 16 =

Using Windows Calculator

Converting decimal to hex Use a calculator that does hex calculations or Use this algorithm repeat divide DecimalNumber by 16, getting Quotient and Remainder; Remainder (in hex) is the next digit (right to left); DecimalNumber := Quotient; until DecimalNumber = 0;

1.2 Character Codes

Character Codes Letters, numerals, punctuation marks and other characters are represented in a computer by assigning a numeric value to each character The system commonly used with microcomputers is the American Standard Code for Information Interchange (ASCII)

Examples of ASCII Codes Printable characters –Uppercase M codes as 4D 16 = –Lowercase m codes as 6D 16 = –Numeral 5 codes as –Space codes as Control characters –Backspace codes as Carriage return CR (0D 16 ) and linefeed LF (0A 16 ) together create a line break

1.3 Unsigned and Signed Integers

Standard Number Lengths Byte – 8 bits Word – 16 bits Doubleword – 32 bits Quadword – 64 bits

Unsigned Representation Just binary in one of the standard lengths E47A is the word-length unsigned representation for the decimal number 58490

Signed Representation 2’s complement representation used in 80x86 One of the standard lengths High-order (leading) bit gives sign –0 for positive –1 for negative For a negative number, you must perform the 2’s complement operation to find the corresponding positive number

2’s Complement Operation +/- button on many calculators Manually by subtracting from 100…0 E47A represents a negative word-length signed number since E = – E47A = 1B86 = , so E47A is the 2’s complement signed representation for minus

Multiple Interpretations One pattern of bits can have many different interpretations The word FE89 can be interpreted as –An unsigned number whose decimal value is –A signed number whose decimal value is -375

1.4 Integer Addition and Subtraction

Addition Same for unsigned and 2’s complement signed numbers, but the results may be interpreted differently The two numbers will be byte-size, word- size, doubleword-size or quadword-size Add the bits and store the sum in the same length as the operands, discarding an extra bit (if any)

Carry If the sum of two numbers is one bit longer than the operand size, the extra 1 is a carry (or carry out). A carry is discarded when storing the result, but we’ll see how the 80x86 CPU records it. For unsigned numbers, a carry means that the result was too large to be stored – the answer is wrong.

Carry In A 1 carried into the high-order (sign, leftmost) bit position during addition is called a carry in. Byte-length example E F DD carry out carry in

Overflow Overflow occurs when there is a carry in but no carry out, or when there is a carry out but no carry in. It recorded by the CPU. If overflow occurs when adding two signed numbers, then the result will be incorrect. Word-length example –Overflow, so AC99 incorrect if viewed as sum of signed numbers –No carry, so AC99 correct if viewed as sum of unsigned numbers 483F + 645A AC99

Subtraction Take the 2’s complement of second number and add it to the first number Overflow occurs in subtraction if it occurs in the corresponding addition CF is set for a borrow in subtraction – when the second number is larger than the first as unsigned numbers. There is a borrow in subtraction when there is not a carry in the corresponding addition.

1.5 Other Systems For Representing Numbers

1’s complement Similar to 2’s complement but to negate a number you flip all its bits. The 1’s complement of is ’s complement rarely used for signed integers in modern systems

Binary Coded Decimal BCD uses four bits to encode each decimal digit 479 could be encoded in two bytes as The Intel architecture has only a few instructions to do arithmetic on BCD numbers

Floating Point IEEE single precision is a popular 32-bit format –Write the number in base 2 “scientific notation” –Sign bit (0 positive, 1 negative) –8 bits for exponent (actual exponent plus a bias of 127) –23 bits for fraction (omitting the leading 1)

Floating Point Example = =  sign + exponent,127+6 in binary fraction, with leading 1 removed and trailing 0’s added to make 23 bits