Lecture 11: Number Systems



Similar documents
CSI 333 Lecture 1 Number Systems

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

NUMBER SYSTEMS. 1.1 Introduction

3. Convert a number from one number system to another

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

Chapter 2. Binary Values and Number Systems

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Section 1.4 Place Value Systems of Numeration in Other Bases

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

NUMBER SYSTEMS. William Stallings

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Binary Representation

Useful Number Systems

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Base Conversion written by Cathy Saxton

CPEN Digital Logic Design Binary Systems

Binary, Hexadecimal, Octal, and BCD Numbers

COMPSCI 210. Binary Fractions. Agenda & Reading

Number Systems. Introduction / Number Systems

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

The string of digits in the binary number system represents the quantity

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

=

Computer Science 281 Binary and Hexadecimal Review

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

2011, The McGraw-Hill Companies, Inc. Chapter 3

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

Lecture 2. Binary and Hexadecimal Numbers

Positional Numbering System

Unsigned Conversions from Decimal or to Decimal and other Number Systems

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Binary Numbers. Binary Octal Hexadecimal

Number Systems and Radix Conversion

Number Representation

Numbering Systems. InThisAppendix...

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

Systems I: Computer Organization and Architecture

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

CS321. Introduction to Numerical Methods

A Step towards an Easy Interconversion of Various Number Systems

Decimal to Binary Conversion

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Lecture 8: Binary Multiplication & Division

CS201: Architecture and Assembly Language

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

Chapter 1: Digital Systems and Binary Numbers

Solution for Homework 2

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

THE BINARY NUMBER SYSTEM

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Number and codes in digital systems

Data Representation. What is a number? Decimal Representation. Interpreting bits to give them meaning. Part 1: Numbers. six seis

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

APPENDIX B. Routers route based on the network number. The router that delivers the data packet to the correct destination host uses the host ID.

BINARY CODED DECIMAL: B.C.D.

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

Verilog - Representation of Number Literals

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

Chapter 4: Computer Codes

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

Measures of Error: for exact x and approximation x Absolute error e = x x. Relative error r = (x x )/x.

Binary Numbering Systems

Computer Science PLUS I Volume 1 : Concepts Government of Tamilnadu

NUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix:

Chapter 5. Binary, octal and hexadecimal numbers

Copyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

Grade 6 Math Circles. Binary and Beyond

Cyber Security Workshop Encryption Reference Manual

Digital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

CHAPTER 5 Round-off errors

Chapter 1. Binary, octal and hexadecimal numbers

Decimal Number (base 10) Binary Number (base 2)

Streaming Lossless Data Compression Algorithm (SLDC)

ELEG3924 Microprocessor Ch.7 Programming In C

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Number of bits needed to address hosts 8

Digital Logic Design. Introduction

Lecture N -1- PHYS Microcontrollers

Math Circle Beginners Group October 18, 2015

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: b + 90c = c + 10b

Addition Methods. Methods Jottings Expanded Compact Examples = 15

Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines in Standard ML. By Prashanth Tilleti

Memory Management Simulation Interactive Lab

HOMEWORK # 2 SOLUTIO

Data Storage 3.1. Foundations of Computer Science Cengage Learning

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

COMBINATIONAL CIRCUITS

IT:101 Cisco Networking Academy I Subnetting

Session 29 Scientific Notation and Laws of Exponents. If you have ever taken a Chemistry class, you may have encountered the following numbers:

Transcription:

Lecture 11: Number Systems

Numeric Data Fixed point Integers (12, 345, 20567 etc) Real fractions (23.45, 23., 0.145 etc.) Floating point such as 23. 45 e 12 Basically an exponent representation

Any number X in fixed point can be represented by a finite sequence of digits X = {x n-1,...x 1, x 0, x -1, x -m }, where, 0 x i < r and -m i n-1 We can compute decimal value of X as follows: V(X) = x i * r i { -m i n-1} OR V(X) = x i * r i {0 i n-1} + x j * r j { -m j -1} integral part fractional part Here r is base (radix) and V(X) is decimal value of X.

Number Systems System Base Digits Examples Decimal 10 0-9 234, 15.23 Binary 2 0 & 1 110101 11011.101 Octal 8 0 7 123, 23.10 Hexadecimal 16 0 9, A,B,C,D,E,F 1AF2, F23.AA

Binary Number System Most modern computer systems operate using binary logic. The computer represents values using two voltage levels (usually 0V for logic 0 and higher V for logic 1). With two levels we can represent exactly two different values. These could be any two different values, but by convention we use the values zero and one. These two values, coincidentally, correspond to the two digits used by the binary number system.

The weighted values for each position is determined as follows: 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 2-1 2-2 128 64 32 16 8 4 2 1 0.5 0.25 Leftmost digit is most significant digit (MSD) whereas rightmost digit is least significant digit (LSD)

Number Base Conversion Binary to Decimal It is very easy to convert from a binary number to a decimal number. Multiply each digit by its weighted position, and add each of the weighted values together. For example, the binary value 11001010 represents: (11001010)b = 1*2 7 +1*2 6 +0*2 5 +0*2 4 +1*2 3 +0*2 2 +1*2 1 + 0*2 = 1*128+1*64+0*32+0*16+1*8+0*4 +1*2+0*1 = 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0 = 202

Decimal to Binary Decimal to binary conversion is slightly more difficult. Repeated Division By 2 divide the decimal number by 2 Remainder is the LSD Quotient becomes new number. This process is continued by dividing the new number by 2 and storing the remainder until the quotient is 0. The remainders are written beginning at the least significant digit (right) and each new digit is written to more significant digit (the left) of the previous digit.

Consider the conversion of 166 to binary number Division Quot Rem Binary Number 166/2 83 0 0 83/2 41 1 10 41/2 20 1 110 20/2 10 0 0110 10/2 5 0 00110 5/2 2 1 100110 2/2 1 0 0100110 1/2 0 1 10100110

Decimal Fraction to Binary fraction Fraction (0.125) 10 = (0.001) b. Use the following method. Repeat the following until fraction becomes 0 or the number of digits have sufficient accuracy. Multiply a decimal fraction by 2. Separate integral and fractional part. new decimal fraction is fractional part obtained above.

Fraction Integral Part New fraction 0.125 * 2 0 0.250 0.250 * 2 0 0.500 0.500 * 2 1 0.000 Collect the integral part as follows: (0.125) 10 = (0.001) 2

Octal Number System Although this was once a popular number base, especially in the Digital Equipment Corporation PDP/8 and other old computer systems, it is rarely used today. The Octal system is based on the binary system with a 3-bit boundary. The Octal Number System: uses base 8 includes only the digits 0 through 7 (any other digit would make the number an invalid octal number) The weighted values for each position is as follows:

The weighted values for each position is determined as follows: 8 5 8 4 8 3 8 2 8 1 8 0 32768 4096 512 64 8 1

Binary to Octal Conversion It is easy to convert from an integer binary number to octal. This is accomplished by: Break the binary number into 3-bit sections from the LSB to the MSB. Convert the 3-bit binary number to its octal equivalent.

For example, the binary value (1010111110110010) 2 will be written: 001 010 111 110 110 010 1 2 7 6 6 2 Corresponding octal number is: (127662) q The base q represent Octal base.

Octal to Binary Conversion It is also easy to convert from an integer octal number to binary number. This is done as follows: Convert the decimal number to its 3-bit binary equivalent. Combine the 3-bit sections by removing the spaces.

For example, the octal value (127662) q will be written : 1 2 7 6 6 2 001 010 111 110 110 010 Corresponding binary number is: (1010111110110010) 2

Octal to Decimal Conversion To convert from Octal to Decimal, multiply the value in each position by its Octal weight and add each value. Using the value from the previous example, (127662) q, we would expect to obtain the decimal value (44978) 10.

Conversion of (127662) q to decimal number 1*8 5 2*8 4 7*8 3 6*8 2 6*8 1 2*8 0 1* 32768 2* 4096 7*512 6*64 6*8 2*1 32768 8192 3584 384 48 2 = 32768 + 8192+ 3584 + 384 +48 + 2 = (44978) 10

Decimal to Octal Conversion To convert decimal to octal is similar to the one done for Decimal to binary. Here repeated division is done by 8. Repeated Division By 8 Divide the decimal number by 8, and write the remainder on the side as the least significant digit. This process is continued by dividing the quotient by 8 and writing the remainder until the quotient is 0.

When performing the division, the remainders which will represent the octal equivalent of the decimal number are written beginning at the LSD (right) and each new digit is written to the next more significant digit (the left) of the previous digit. Consider decimal number (166) 10. Convert to its equivalent Octal number.

Division Quot Rem Octal Number 166/8 20 6 6 20/8 2 4 46 2/8 0 2 246 Therefore, (166) 10 = (246) 8 or (246) q

Hexadecimal Number System The Hexadecimal Number System: uses base 16 includes only the digits 0 through 9 and the letters A, B, C, D, E, and F Hexadecimal numbers offer the two features: hex numbers are very compact it is easy to convert from hex to binary and binary to hex. The Hexadecimal system is based on the binary system using 4-bit (a Nibble) boundary. In the Hexadecimal number system, the hex values greater than 9 carry the following decimal value:

Binary (b) Decimal Hex(h) (0000) b (0) 10 (0) h (0001) b (1) 10 (1) h (0010) b (2) 10 (2) h (0011) b (3) 10 (3) h (0100) b (4) 10 (4) h (0101) b (5) 10 (5) h (0110) b (6) 10 (6) h (0111) b (7) 10 (7) h (1000) b (8) 10 (8) h (1001) b (9) 10 (9) h

Binary (b) Decimal Hex(h) (1010) b (10) 10 (A) h (1011) b (11) 10 (B) h (1100) b (12) 10 (C) h (1101) b (13) 10 (D) h (1110) b (14) 10 (E) h (1111) b (15) 10 (F) h

Hexadecimal to Binary Conversion simply brake the binary number into 4-bit groups beginning with the LSB and substitute the corresponding four bits in binary for each hexadecimal digit in the number. For example, to convert (ABCD) h into a binary value, simply convert each hexadecimal digit according to the table above. The binary equivalent is: (ABCD) h = (1010 1011 1100 1101) 2

Binary to Hex Conversion It is easy to convert from an integer binary number to hex. This is accomplished by: Break the binary number into 4-bit sections from the LSB to the MSB. Pad the binary number with leading zeros if needed. Convert the 4-bit binary number to its Hex equivalent. For example, the binary value (110111110110010) 2 will be written: (011 0 1111 1011 0010) 2 = (6FB2) h

Hex Decimal Conversion Hex to Decimal conversion Multiply the value in each position by its hex weight and add each value. We would expect to obtain the decimal value (44978) 10 corresponding to (AFB2) h. A*16 3 + F*16 2 + B*16 1 + 2*16 0 = 10*4096 +15*256 +11*16 + 2*1 = 40960 + 3840 + 176 + 2 = (44978) 10 Decimal to Hex Conversion The typical method to convert from decimal to hex is repeated division by 16 (similar to other bases).

Base (r) Decimal Conversion Base r to Decimal Assume {x n-1,...x 1, x 0, x -1, x -m } in base r, X = + x 2 * r 2 + x 1 * r 1 + x 0 * r 0 + x -1 * r -1 + Decimal to Base r Repeated Division By r Write the remainder on the side as the LSD. This process is continued by dividing the quotient by r and writing the remainder until the quotient is 0.