ICS312 Set 1 Representation of Numbers and Characters.

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

ICS312 Set 2 Representation of Numbers and Characters.
Representing Numbers: Integers
HEXADECIMAL NUMBERS Code
Data Representation Computer Organization &
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Data Representation COE 205
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Data Representation ICS 233
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Chapter 1 Number Systems and Codes 1. Outline 1. NUMBER SYSTEMS AND CODES 2. DIGITAL ELECTRONIC SIGNALS AND SWITCHES 3. BASIC LOGIC GATES 4. PROGRAMMABLE.
Binary and Hexadecimal Numbers
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
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.
Digital Systems and Logic Design
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
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.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
CPU Internal memory I/O interface circuit System bus
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
The Hexadecimal Number System and Memory Addressing ISAT 121.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
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.
1 Review on Number Systems Decimal, Binary, and Hexadecimal.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
Number Systems by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.
MECH1500 Chapter 3.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
Computer Organization 1 Data Representation Negative Integers.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Data Representation COE 308 Computer Architecture
Number Systems and Codes
NUMBER SYSTEMS.
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
Data Representation Binary Numbers Binary Addition
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 : INTRODUCTION
BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.
Data Representation COE 301 Computer Organization
Number Systems and Codes
Number Systems Lecture 2.
C1 Number systems.
Data Representation ICS 233
ECE 331 – Digital System Design
Computer Architecture CST 250
Data Representation COE 308 Computer Architecture
Presentation transcript:

ICS312 Set 1 Representation of Numbers and Characters

Number Systems - Decimal System (base 10) Uses positional representation Each digit in a number is associated with a power of 10 based on its position in the number. The one's digit (zero power of 10) is the rightmost digit and the powers of 10 increase as you move to the left. 5,325 = 5 * * * * 10 0 For the decimal system: 10 = base 10 digits are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 The concept of positional representation applies to the binary and hexadecimal numbering systems as well.

Number Systems - Binary Number System Base = 2 2 Digits: 0, 1 Examples: 1001b = 1 * * * * 2 0 = = b = 1 * * * * = = 173 Note: it is common to put binary digits in groups of 4 to make it easier to read them.

Number Systems - Hexadecimal Number System Used as a shorter, easier to read notation than binary. Base = digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E,F Examples: 10h = 1 * * 16 0 = 16 (decimal) 200h = 2 * 16^2 = 2 * 256 = h = 4 * 16^ = 69 3Fh = 3 * = = 63

Converting from binary or hex to decimal: Use positional representation to expand the number and convert to decimal equivalent. Examples: b 015Eh

Converting from decimal to binary: Use repeated division by 2. The remainders give the binary digits, starting from the lowest power of 2. Examples: Convert Division Step Quotient/Remainder Binary Digits

Converting from hex to binary Rewrite each hex digit as its (4-digit) binary equivalent. Examples: Hex Value Binary equivalent 4Bh 32FFh F38Bh

Converting from binary to hex Rewrite each group of 4 binary digits as its hex equivalent. Pad zeroes on the left as needed. Examples: Binary Hex Equivalent b b

Converting from decimal to hexadecimal: It’s simplest to convert the decimal number to binary and then convert that binary number to hexadecimal.

Arithmetic Apply the same concepts as for decimal arithmetic to binary and hexadecimal arithmetic.

Binary Addition: Underlying examples: how carries work b = 10b b = 10b + 1 = 11b Examples: 0011b b b b =

Hexadecimal Addition: Underlying examples: how carries work F + 1 h = 10h E + 2 h = 10h A + B h = 10d + 11d = 21d = 15h Examples: 4Ah + 5Bh = 4B7Fh + 2A93h =

Representing Integers in the Computer (1) Signed Numbers and Unsigned Numbers Most Significant Bit (MSB) leftmost or high-order bit (bit 15 or 7) Least Significant Bit (LSB) rightmost or low-order bit (bit 0)

Representing Integers in the Computer (2) 1's Complement Formed by reversing (complementing) each bit of value. 2's Complement form Formed by adding 1 to 1's complement of a number. Examples: Express -9 in 2's complement form (8-bit) Add 9 and its 2's complement value, ignoring carries: What is 2's complement of –5? Calculate using 2's complement form for –5, ignoring carries.

Representing Integers in the Computer (3) Signed Integers Allows positive and negative integers to be represented MSB (most significant bit)is used to indicate sign: 0 = positive, 1 = negative The computer stores negative numbers in 2’s complement form Since 1 bit is used to represent the sign, only 7 or 15 bits can be used for the magnitude in a byte or word (2 bytes) respectively: 1 byte = 8-1 bits = 2 7 => range = -128 to word = 2 bytes = 16-1 bits = 2 15 => range = -32,768 to 32,767

Intel's peculiar method of storing multibyte numbers in the computer Note: each hex digit is encoded in a nibble (4 bits). e.g., = BAh Example of a multibyte number: 3A 4D is a 2 byte hex number The memory of the computer is numbered byte 0, byte 1, byte 2,.. For this example, if the number is stored at bytes 20 and 21, it is stored as follows: byte 20byte 21 4D 3A

Intel's peculiar method of storing multibyte numbers in the computer (Cont. 1) The address of the 2 byte word (a word is 2 bytes, a byte is 8 bits) is given as the lowest address used, which is byte 20. Note again that the bytes are stored in reverse order with the least significant byte at the lowest memory address and the most significant byte stored at the highest memory address.

Intel's peculiar method of storing multibyte numbers in the computer (Cont. 2) Example with a double word (= 2 words or 4 bytes). E.g., 32 4A 3F 22h This would be stored in memory as: memory contents:223F4A32 byte # in memory: The address for the (entire) number stored in memory is 50, which is the lowest memory address used.

Character Representation ASCII American Standard Code for Information Interchange Standard encoding scheme used to represent characters in binary format on personal computers 7-bit encoding => 128 characters can be represented codes 0-31 and 127 are control characters (nonprinting characters) control characters used on PC's are: LF, CR, BS, Bell, HT, FF

Character Representation (Cont.) ASCII characters codes are used for input and output. E.g., when the number 5, is entered on the keyboard, the value read into the processor is the ASCII character code 35h. In order to do numeric processing, the ASCII code must be converted to the true numeric value by subtracting 30h, which gives the value 5. Then, before the result can be displayed the numeric value must be reconverted to an ASCII code which can be displayed

Character Representation (Cont.) UNIDEC is a system (supported e.g by HTML) for representing characters employing 2 bytes per character. With 2 16 possible characters, it is possible to include characters of languages other that English, such as Chinese,Korean, Russian, etc.