Number Representation (Part 1) Computer Architecture (Fall 2006)

Slides:



Advertisements
Similar presentations
Number Systems and Codes
Advertisements

Representing Numbers: Integers
DATA REPRESENTATION CONVERSION.
Level ISA3: Information Representation
The Binary Number System
Introduction to Number Systems
Converting Binary to Octal
 Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal.
Binary Numbers.
Computer Science 101 Number Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.
Number Systems Computer Science 210 Computer Organization.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. 1 Number Systems 0, 1 0, 1, 2, 3, 4, 5, 6, 7 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 0, 1, 2, 3,
Digital Logic Chapter 2 Number Conversions Digital Systems by Tocci.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Numeral Systems Subjects: Numeral System Positional systems Decimal
CSC212 – Computer Organization and Design
IT253: Computer Organization
Chapter 3 Data Representation
Number Systems Spring Semester 2013Programming and Data Structure1.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Number systems: binary, decimal, hexadecimal and octal. Conversion between various number systems Number systems: binary, decimal, hexadecimal and octal.
Lecture 2 Bits, Bytes & Number systems
CCE-EDUSAT SESSION FOR COMPUTER FUNDAMENTALS Date: Session III Topic: Number Systems Faculty: Anita Kanavalli Department of CSE M S Ramaiah.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Number Systems 0, 1 0, 1, 2,
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
Data Representation, Number Systems and Base Conversions
AEEE2031 Data Representation and Numbering Systems.
June 10, 2002© Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
Number Representation (Part 2) Computer Architecture (Fall 2006)
ECE DIGITAL LOGIC LECTURE 2: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/14/2016.
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.
1. Binary, Decimal, Hexadecimal and Octal. 2. Conversion between various number systems. Number Systems:
DECIMAL, BINARY, AND HEXADECIMAL. Decimal Numbering System Ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Represent larger numbers as a sequence of digits.
Number Systems & Binary Arithmetic
Topic: Binary Encoding – Part 2
Binary & Hex Review.
Computer Science 210 Computer Organization
Appendix F Number Systems binary 0, 1 0, 1, 2, 3, 4, 5, 6, 7
Topic: Binary Encoding – Part 1
Chapter 2 Binary Number Systems.
Bits, Data Types, and Operations
Programming and Data Structure
Number Systems and Codes
NUMBER SYSTEMS.
Lec 3: Data Representation
Number Representation
What is a byte? What is it? How would you use it?
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Computer Science 210 Computer Organization
CSE 102 Introduction to Computer Engineering
Chapter 3 Data Representation
2.0 COMPUTER SYSTEM 2.2 Number System and Representation
Number Systems.
Computer Science 210 Computer Organization
Number Systems and Codes
Computer Science 210 Computer Organization
Number Representation
COMS 161 Introduction to Computing
Binary & Hex Review.
OBJECTIVES After reading this chapter, the reader should be able to :
Networks & I/O Devices.
CHAPTER 69 NUMBER SYSTEMS AND CODES
Presentation transcript:

Number Representation (Part 1) Computer Architecture (Fall 2006)

Its all 1s and 0s! Computers operate using bits –Everything is ultimately a “1” or a “0” Mind Bender –If everything is a “1” or a “0” then how does the computer: Show and edit video? Compose and play music? Display and modify pictures? Learn and recognize speech?

Magic of Interpretation The key is interpretation –Different sequence of 1s and 0s are assumed to convey different meanings to different devices –Example: What does bits 1011 imply Letter “A” on the keyboard A number (11) to the CPU Color red to the video card Music note F# to the sound card Sector number 11 to the hard disk drive

Standards Interpretations can be problematic –Different interpretations can lead to confusion –Problems with portability & interoperability Solution: Standards –Standard ways to represent data –Different data types need different standards –Integers have different representation versus floating point numbers –Numbers have different representation than characters and strings Depending on needs Efficiency of hardware implementation

Integer representation Several standards are available Mirrors standard mathematical representation of numbers for most part –Subdivided into 2 main categories –Unsigned integer representation Standard binary number representation –Signed integer representation Sign-bit Magnitude representation 1’s Complement representation 2’s Complement representation

Background on number representation Number representation are based on mathematical representation of decimal numbers –Uses 10 symbols (0 through 9) to represent 10 different values –Uses powers of 10 and a sequence of above symbols to represent larger values

Think Time Standard number conversions Break 345 into Units, tens, & hundredths place Remainder Combine the digits shown below into a number Value=(3*10 2 )+(4*10 1 )+ (5*10 0 ) = = 345

Binary number representation In Binary system there are only 2 symbols “1” and “0” –Yields base-2 representation –This enables representation of 2 unique values Namely 0 2 = 0 10 and 1 2 =1 10 d –Notice the use of base values for numbers! –Analogous to the decimal system, larger numbers are represented using sequence of “1”s and “0s” Each position indicates a specific power of Example binary number:

Unsigned Decimal to Unsigned Binary Conversion Performed through successive division by 2 –Until quotient becomes 1 –Writing remainders in reverse order Example convert 5 10 to binary 25 Remainder = 101 2

Example 2 Convert 12 to binary =

Fixed Size Representation Numbers are represented using a fixed number of bits –Typically a word is used A word can be 8, 16, 32, or 64 bits depending on how a given machine is designed. –Representation mechanism Convert decimal to binary Pad binary with leading 0s to fit given word size

Example Represent as a 8-bit binary number –Solution: Convert to binary which is Now as 8-bit number = –Padding 4 leading 0s to make it 8-bits wide Represent 39 as a 5-bit binary number –Solution: Convert to binary which is –Cannot fit 6-bits into 5-bits position! Drop left-most digits as necessary –Result =

Binary to Decimal Conversion Multiply by powers of 2 and add –Powers of 2 increase from left to right! Example: Convert to decimal Decimal = (1*2 2 ) + (1*2 1 ) + (0*2 0 ) = = = 6 10

Binary to Decimal Conversion (Example 2) Example: Convert to decimal –Value = (1*2 4 )+(1*2 3 )+(0*2 2 )+(1*2 1 )+(0*2 1 ) = = 26 – = Tip for verification –Even valued binary numbers have 0 at the end –Odd valued binary numbers have 1 at the end

Table of Values Decimal (Base-10)Binary (Base-2)

Range of numbers Given a unsigned binary number with K positions –Minimum number = 0 –Maximum number = 2 K -1 Example if K = 8 –With 8 bits, maximum number = = 255

Octal representation Octal representation is to the base-8 –Uses symbols “0” through “7” to represent 8 different values –Uses sequence of symbols for larger numbers. Convenient for representation of larger numbers –Easy to convert between Octal & binary –Requires fewer display places on hardware devices

Decimal to Octal Conversion Performed through successive division by 8 Similar in philosophy to other conversions –Until quotient becomes less than 8 –Writing remainders in reverse order Example: Convert to Octal = 123 8

Octal to Decimal Conversion Example: Convert to decimal –Value = (5*8 2 )+(6*8 1 )+(7*8 0 ) = = 375 –567 8 =

Octal to Binary Conversion Simply write 3-bit binary representation for each digit as if it was a decimal digit 3-bits are needed to represent 8 different values (0 to 7) for each digit in the octal representation –In a left to right manner Example: Convert to binary –1 8 = –2 8 = –3 8 = –123 8 =

Binary to Octal Conversion Organize bits in binary number in sets of 3 –From right to left manner –Write decimal value for each set of 3 bits Range of values will be from 0 to 7 Example: Convert to Octal – – –260 8

Hexadecimal Representation Hexadecimal (or Hex) uses Base-16 –Requires 16 symbols for values 0 to 15 Uses standard numerals for 0 to 9 Uses A through F for values 10 to 15 DecHexDecHex A B C D E F 16

Motivation for Hex Primarily for display purposes –Originally intended for 7-segment displays –Still used in conventional computers for display of binary information Such as memory addresses etc.

Decimal to Hex Conversion Performed through successive division by 16 Similar in philosophy to other conversions –Until quotient becomes less than 16 –Writing remainders in reverse order Example: Convert to Hex E (14 10 ) D (13 10 ) = 2DE 16

Hex to Decimal Conversion Example: Convert A8F 16 to decimal –Value = (A*16 2 )+(8*16 1 )+(F*16 0 ) = (10*16 2 )+(8*16 1 )+(15*16 0 ) = = 2703 –A8F 16 =

Hexal to Binary Conversion Simply write 4-bit binary representation for each digit as if it was a decimal digit 4-bits are needed to represent 16 different values (0 to F) for each digit in the hexal representation –In a left to right manner Example: Convert 1C3 16 to binary –1 16 = –C 16 = –3 16 = –1C3 16 =

Binary to Hexal Conversion Organize bits in binary number in sets of 4 –From right to left manner –Write decimal value for each set of 4 bits Range of values will be from 0 to F Example: Convert to Hexal – – –130 16

Table of Equivalent Values Dec.BinaryOctalHexalDec.BinaryOctalHexal A B C D E F 16