Tasanawan Soonklang Department of Computing, Faculty of Science Data Representation.

Slides:



Advertisements
Similar presentations
HEXADECIMAL NUMBERS Code
Advertisements

Chapter 2 : Number System
Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
ECE 331 – Digital System Design
Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
Data Representation in Computers
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Data Storage. SIGN AND MAGNITUDE Storing and representing numbers.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
1.6 Signed Binary Numbers.
Representing text Each of different symbol on the text (alphabet letter) is assigned a unique bit patterns the text is then representing as.
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Logic and Digital System Design - CS 303
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
Binary Arithmetic & Data representation
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
NUMBER SYSTEM AND COMPUTER CODES Chapter 2. Prelude Fingers, sticks, and other things for counting were not enough! Counting large numbers Count in groups.
Number Systems Spring Semester 2013Programming and Data Structure1.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
CE1111 :Digital Logic Design lecture 01 Introduction Dr. Atef Ali Ibrahim.
Computer Systems Architecture Copyright © Genetic Computer School 2008 CSA 1- 0 Lesson 1 Number System.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Chapter 1: Digital Computers and Information Illustration at beginning of each Chapter Base 10 Binary Base 2 Octal Base 8 Hex bas
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
Data Representation, Number Systems and Base Conversions
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
SAK Chapter 21 Chapter 2 : Number System 2.1 Decimal, Binary, Octal and Hexadecimal Numbers 2.2 Relation between binary number system with other.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
NUMBER SYSTEMS AND CODES. CS Digital LogicNumber Systems and Codes2 Outline Number systems –Number notations –Arithmetic –Base conversions –Signed.
Chapter 1 : Introduction to Binary Systems 1.1. Introduction to Digital Systems 1.2. Binary Numbers 1.3. Number Base Conversion 1.4. Octal and Hexadecimal.
DATA REPRESENTATION 4 Y. Colette Lemard February 2009.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
BINARY SYSTEMS ENGR. KASHIF SHAHZAD 1. BINARY NUMBERS 1/2 Internally, information in digital systems is of binary form groups of bits (i.e. binary numbers)
Computer Math CPS120 Introduction to Computer Science Lecture 7.
DATA REPRESENTATION Data Types Complements Fixed Point Representations
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.
Advanced Binary b. describe and use two’s complement and sign and magnitude to represent negative integers; c. perform integer binary arithmetic, that.
11001 / 101, / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the result.
Lecture 4: Digital Systems & Binary Numbers (4)
Lecture Coding Schemes. Representing Data English language uses 26 symbols to represent an idea Different sets of bit patterns have been designed to represent.
Cosc 2150: Computer Organization
Number Representation
11001 / 101 , / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the.
CHAPTER 1 : INTRODUCTION
CSE 102 Introduction to Computer Engineering
Chapter 3 Data Representation
Number Systems.
COMS 161 Introduction to Computing
COMS 161 Introduction to Computing
Number Systems Rayat Shikshan Sanstha’s
Number Systems Rayat Shikshan Sanstha’s
ECE 331 – Digital System Design
Presentation transcript:

Tasanawan Soonklang Department of Computing, Faculty of Science Data Representation

Introduction Switching circuit : On, Off  Number representation Number system Number conversion  Integer Arithmetic Addition Subtraction Negation

Introduction  Signed integer representation Sign magnitude Ones complement Twos complement  Character representation ASCII EBCDIC Unicode

Number representation  Number system N = b n b n-1 b n-2 …b 2 b 1 b 0.b -1 b -2 …b -m  r number (base-r) : 0,1,2,…,r-1 Binary (base2) : 0,1 Octal (base8) : 0,1,2,3,4,5,6,7 Decimal (base10) : 0,1,2,3,4,5,6,7,8,9 Hexadecimal (base16) : 0,1,2,3,4,5,6,7,8,9, A,B,C,D,E,F

Number conversion Integer part N = b n 2 n + b n-1 2 n-1 + … + b b 0 1 (123) 10 = (1*10 2 ) + (2*10 1 ) + (3*10 0 ) Position bnbn b n-1 … b2b2 b1b1 b0b0 Base2 Base8 Base10 Base16 2 n 8 n 10 n 16 n 2 n-1 8 n-1 10 n n- 1 …………………………

Number conversion Base-r to decimal  (11011) 2 = 1* * * * *2 0 = 1*16 + 1*8 + 0*4 + 1*2 + 1*1 = = 27  (1276) 8 = 1* * * *8 0 =  (2EA7) 16 = 2* A* E* *16 0 = 2* * *16 + 7

Number conversion Decimal to base-r (702) 10 = (1276) 8 8 ) ) ) ) (1632) 10 = (660) ) ) ) (19) 10 = (10011) 2 2 ) 19 mod 2 ) ) ) )

Number conversion fraction part N = b b …+ b -(m-1) 2 -(m-1) + b -m 2 - m position B -1 b -2 B -3 … B -(m-1) bmbm Base2 Base8 Base10 Base ………………………… 2 -(m-1) 8 -(m-1) 10 -(m-1) 16 -(m-1) 2 -m 8 -m 10 -m 16 -m

Number conversion Base-r to decimal  (.011) 2 = 0* * *2 -3 = 0 + 1/4 + 1/8 =  (.1142) 8 = 1* * * *8 -4 = 1/8 + 1/64 + 4/ /4098  (.1A) 16 = 1* A*16 -2 = 1/ /256

Number conversion Decimal to base-r (.375) 10 = (.011) * * * *

Integer arithmetic  Addition aba+b carry  Subtraction aba-b carry

Integer arithmetic  Bitwise complement Take the Boolean complement of each bit That is, set each 1 to 0 and each 0 to 1  Negation Add 1 to the result  Twos complement operation Two-step process Bitwise + negation bitwise

Signed integer representation  Sign magnitude  Ones complement  Twos complement

Sign magnitude  Assign the high-order (leftmost) bit to the sign bit 0 -> positive (+) 1 -> negative (-)  The remaining (m-1) bits represent the magnitude of the number  Adv : familiarity  Problem : positive & negative zero

Sign magnitude  8 bits : 1 sign bit, 7 magnitude base10base = 256 numbers

Ones complement  Similar to sign magnitude  Assign the high-order bit to the sign bit 0 -> positive (+) 1 -> negative (-)  Take the bitwise complement of the remaining bits to represent the magnitude  Problem : positive & negative zero

Ones complement  8 bits : 1 sign bit, 7 magnitude base10base = 256 numbers

Twos complement  Similar to ones complement  Assign the high-order bit to the sign bit 0 -> positive (+) 1 -> negative (-)  Take the twos complement operation of the remaining bits to represent the magnitude  Solution for positive & negative zero

Twos complement  8 bits : 1 sign bit, 7 magnitude base10base = bitwise = 0 ignore overflow -8 = bitwise (-8) = -8 monitor sign bit

Addition & Subtraction  Normal binary addition  Monitor sign for overflow  Overflow : the result is larger than can be held in the word size  Take twos compliment of subtrahend and add to minuend  A – B = A + (-B)

Twos complement  8 bits : 1 sign bit, 7 magnitude  The negative of the negative of that number is itself. +18 = bitwise = = = bitwise = = +18

Twos complement

Character representation  BCD – Binary code decimal  EBCDIC – Extended binary code decimal interchange code  ASCII – American standard code for information interchange  Unicode

BCD  Binary system  6 bits for representing 1 character  2 6 = 64 codes  2 parts : Zone Bit (first 2 bits) and Numeric Bit (last 4 bits)

EBCDIC  Binary system  8 bits for representing 1 character  2 8 = 256 codes  2 parts : Zone Bit (first 4 bits) and Numeric Bit (last 4 bits)  Developed by IBM

EBCDIC CharacterZoneDigit A,B,C,…,I J,K,L,…,R S,T,U,…,Z ,1,2,…, a,b,c,…,i j,k,l,…,r s,t,u,…,z blank,$,.,,(, &,!,*,),; ,/,’,_,?

ASCII  8 bits for representing 1 character  2 8 = 256 codes  3 parts consist of 0-32 : control character (lower ASCII): English alphabets, numbers, symbols (higher ASCII) : other language alphabets (e.g. Thai)  Developed by ANSI (American national standard institute)

ASCII Lower ASCII Higher ASCII

Unicode  16 bits for representing 1 character  2 16 = 65,536 codes  Enough for alphabets in other language such as Chinese, Japanese special symbols such as mathematic symbols  Widely use in many operating systems, applications and programming languages  Developed by Unicode consortium

Unicode  16 bits for representing 1 character  2 16 = 65,536 codes  Enough for alphabets in other language such as Chinese, Japanese special symbols such as mathematic symbols  Widely use in many operating systems, applications and programming languages  Developed by Unicode consortium

Unit NameAbbr.SizeByte KiloK2 10 1,024 MegaM2 20 1,048,576 GigaG2 30 1,073,741,824 TeraT2 40 1,099,511,627,776 PetaP2 50 1,125,899,906,842,624 ExaE2 60 1,152,921,504,606,846,976 ZettaZ2 70 1,180,591,620,717,411,303,424