2.1 Binary Numbers. 2.3 Number System Conversion. From Binary to Decimal. From Decimal to Binary. Section 2 Binary Number System Page 1 of 8

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

Computer Science 281 Binary and Hexadecimal Review

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

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

Systems I: Computer Organization and Architecture

Useful Number Systems

Number Representation

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

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

CSI 333 Lecture 1 Number Systems

Lecture 11: Number Systems

Unsigned Conversions from Decimal or to Decimal and other Number Systems

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

Lecture 2. Binary and Hexadecimal Numbers

Solution for Homework 2

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

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

Binary Representation

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

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:

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

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

Chapter 1: Digital Systems and Binary Numbers

NUMBER SYSTEMS. 1.1 Introduction

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

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

HOMEWORK # 2 SOLUTIO

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

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

Numbering Systems. InThisAppendix...

Chapter 4: Computer Codes

Base Conversion written by Cathy Saxton

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

Section 1.4 Place Value Systems of Numeration in Other Bases

COMPSCI 210. Binary Fractions. Agenda & Reading

CPEN Digital Logic Design Binary 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

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

Binary, Hexadecimal, Octal, and BCD Numbers

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

CS201: Architecture and Assembly Language

NUMBER SYSTEMS. William Stallings

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

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

Binary Numbering Systems

CS321. Introduction to Numerical Methods

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

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

3. Convert a number from one number system to another

Chapter 2. Binary Values and Number Systems

Positional Numbering System

Number and codes in digital systems

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

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

Binary Numbers. Binary Octal Hexadecimal

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

THE BINARY NUMBER SYSTEM

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

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

Digital Logic Design. Introduction

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

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

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

CHAPTER 5 Round-off errors

Unpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

Lecture 8: Binary Multiplication & Division

Number Systems. Introduction / Number Systems

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

BINARY CODED DECIMAL: B.C.D.

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

Number Systems and Radix Conversion

Chapter 1. Binary, octal and hexadecimal numbers

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

ASCII Characters. 146 CHAPTER 3 Information Representation. The sign bit is 1, so the number is negative. Converting to decimal gives

DNA Data and Program Representation. Alexandre David

Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:

=

Data Storage. 1s and 0s

2.2 Scientific Notation: Writing Large and Small Numbers

What Every Computer Scientist Should Know About Floating-Point Arithmetic

Verilog - Representation of Number Literals

The New IoT Standard: Any App for Any Device Using Any Data Format. Mike Weiner Product Manager, Omega DevCloud KORE Telematics

Exponents. Learning Objectives 4-1

Recall the process used for adding decimal numbers. 1. Place the numbers to be added in vertical format, aligning the decimal points.

A Step towards an Easy Interconversion of Various Number Systems

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

Z80 Instruction Set. Z80 Assembly Language

Chapter 5. Binary, octal and hexadecimal numbers

YOU MUST BE ABLE TO DO THE FOLLOWING PROBLEMS WITHOUT A CALCULATOR!

Counting in base 10, 2 and 16

THE EXACT DOT PRODUCT AS BASIC TOOL FOR LONG INTERVAL ARITHMETIC

Attention: This material is copyright Chris Hecker. All rights reserved.

A Short Guide to Significant Figures

The Answer to the 14 Most Frequently Asked Modbus Questions

Logic Reference Guide

This section describes how LabVIEW stores data in memory for controls, indicators, wires, and other objects.

RN-coding of Numbers: New Insights and Some Applications

Transcription:

Section Binary Number System Page 1 of 8.1 Binary Numbers The number system we use is a positional number system meaning that the position of each digit has an associated weight. The value of a given number is equivalent to the weighted sum of all its digits. e.g. Here, 10 is the base or radix of the number system. Use a subscript to indicate the radix of the number. In general 134.56 10 = 1 10 3 + 10 + 3 10 1 + 4 10 0 + 5 10-1 + 6 10 - d m 1 m 1d m d1d 0d 1d d n = d i i= n The leftmost digit is called the most-significant digit (MSD). The rightmost digit is called the least-significant digit (LSD). Digital systems use binary digits with a binary radix. r i 110.101 = 1 + 1 10 1 + 0 10 0 + 1 10-1 + 0 10 - + 1 10-3 = 6.65 10.3 Number System Conversion From Binary to Decimal 10001011 = 1 7 + 0 6 + 0 5 + 0 4 + 1 3 + 0 + 1 1 + 1 0 = 18 + 8 + + 1 From Decimal to Binary 139 1 LSD 69 1 34 0 17 1 8 0 4 0 0 1 MSD 139 10 = 10001011

Section Binary Number System Page of 8. Octal and Hexadecimal Numbers Binary numbers are too long to write so we use a shorthand notation: Octal base 8; needs 8 different values; 0 to 7. Hexadecimal base 16; needs 16 different values; 0 to 9, A to F. Binary (radix ) Octal (radix 8) Decimal (radix 10) Hexadecimal (radix 16) 0000 0 0 0 0001 1 1 1 0010 0011 3 3 3 0100 4 4 4 0101 5 5 5 0110 6 6 6 0111 7 7 7 1000 10 8 8 1001 11 9 9 1010 1 10 A 1011 13 11 B 1100 14 1 C 1101 15 13 D 1110 16 14 E 1111 17 15 F.3 Number System Conversion From Binary to Octal Starting at the binary point, separate the bits into groups of three and replace each group with the corresponding octal digit. 10001011 = 010 001 011 = 13 8 11.10111 = 011. 101 110 = 3.56 8 From Octal to Binary Replace each octal digit with the corresponding 3-bit binary string. 13 8 = 010 001 011 = 10001011 From Binary to Hexadecimal Starting at the binary point, separate the bits into groups of four and replace each group with the corresponding hexadecimal digit. 10001011 = 1000 1011 = 8B 16 11.10111 = 0011. 1011 1000 = 3.B8 16 From Hexadecimal to Binary Replace each hexadecimal digit with the corresponding 4-bit binary string. 8B 16 = 1000 1011 = 10001011

Section Binary Number System Page 3 of 8 From Octal to Decimal 51 8 = 5 8 3 + 8 + 8 1 + 1 8 0 = 560 + 18 + 16 + 1 = 705 10 From Decimal to Octal 8 8 8 705 1 LSD 338 4 5 MSD 705 10 = 51 8 From Hexadecimal to Decimal A9C 16 = 10 16 + 9 16 1 + 1 16 0 = 560 + 144 + 1 = 716 10 From Decimal to Hexadecimal 16 16 716 C LSD 169 9 A MSD 716 10 = A9C 16 Examples: Binary Octal Decimal Hex 10011010 3 154 9A 10111000101 705 1477 5C5 101010010001 51 705 A91 1110111100 1674 956 3BC

Section Binary Number System Page 4 of 8.4 Add 1 1 1 1 1 0 0 1 1 + 1 0 0 1 + 1 1 1 0 1 1 0 0 0 1 0 0 0 0 1.4 Subtract 1 1 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0.7 Multiply normally for implementation - add the shifted multiplicands one at a time. 1 1 1 0 = 14 1 1 1 0 * 1 1 0 1 = 13 * 1 1 0 1 1 1 1 0 1 1 1 0 0 0 0 0 + 0 0 0 0 1 1 1 0 0 1 1 1 0 + 1 1 1 0 + 1 1 1 0 1 0 1 1 0 1 1 0 1 0 0 0 1 1 0 + 1 1 1 0 1 0 1 1 0 1 1 0 (8 bits)

Section Binary Number System Page 5 of 8.8 Divide 1 1 0 1 1 1 0 1111) 11000101 1101) 1011001 1 1 1 1 1 1 0 1 1001101 100101 1 1 1 1 1 1 0 1 10001 1011 0 0 0 0 0 0 0 0 10001 1011 1 1 1 1 10 1 0 0 1 1101) 1111001 1 1 0 1 10001 0 0 0 0 10001 0 0 0 0 10001 1 1 0 1 100

Section Binary Number System Page 6 of 8.5 Representation of Negative Numbers Sign-Magnitude The most significant bit is the sign bit and the rest of the number is the magnitude. 0 = positive 1 = negative n bit range = -( n-1-1) to +( n-1-1) 4 bits range = -7 to +7 possible representation of zero, +0 and -0. 's Complement flip bits and add one. n bit range = -( n-1 ) to +( n-1-1) 4 bits range = -8 to +7 0 0 0 0 = 0 0 0 0 1 = 1 0 0 1 0 = 0 0 1 1 = 3 0 1 0 0 = 4 0 1 0 1 = 5 0 1 1 0 = 6 0 1 1 1 = 7 1 0 0 0 = -8 1 0 0 1 = -7 1 0 1 0 = -6 1 0 1 1 = -5 1 1 0 0 = -4 1 1 0 1 = -3 1 1 1 0 = - 1 1 1 1 = -1 Example 0 1 1 0 = 6 1 0 0 1 flip bits 1 0 1 0 add one = -6 1 1 1 0 = 14 0 0 0 1 flip bits 0 0 1 0 add one WRONG this is not -14. Out of range. Need 5 bits 0 1 1 1 0 = 14 1 0 0 0 1 flip bits 1 0 0 1 0 add one. This is -14. Sign Extend add 0 for positive numbers add 1 for negative numbers

Section Binary Number System Page 7 of 8 Add 's Complement 1110 = - 1110 =- + 1 1 0 1 = -3 + 0 0 1 1 = 3 1 1011 ignore carry = -5 10001 ignore carry = 1 Be careful of overflow errors. An addition overflow occurs whenever the sign of the sum is different from the signs of both operands. Ex. 0100 = 4 1100 =-4 + 0 1 0 1 = 5 + 1 0 1 1 = -5 1001 = -7 WRONG 10111 ignore carry = 7 WRONG Subtract 's Complement 0010 = + 1 1 1 0 = - 1 0000 ignore carry = 0 Multiply 's Complement 1110 = - 1110 =- * 1 1 0 1 = -3 * 0 0 1 1 = 3 11111110 sign extend to 8 bits 11111110 sign extend to 8 bits + 0 0 0 0 0 0 0 + 1 1 1 1 1 1 0 11111110 111111010 ignore carry = -6 + 1 1 1 1 1 0 1 11110110 ignore carry + 0 0 0 1 0 negate - for sign bit 1 00000110 ignore carry = 6 10010 = -14 * 1 0 0 1 1 = -13 1111110010 sign extend to 10 bits + 1 1 1 1 1 0 0 1 0 1 1111010110 ignore carry + 0 0 0 0 0 0 0 0 1111010110 + 0 0 0 0 0 0 0 1111010110 + 0 0 1 1 1 0 negate -14 for sign bit 1 0010110110 ignore carry = 18

Section Binary Number System Page 8 of 8.9 Floating-Point Numbers mantissa x (radix) exponent The floating-point representation always gives us more range and less precision than the fixed-point representation when using the SAME number of digits. Mantissa sign Sign exponent Mantissa magnitude General format 0 1 9 31 Mantissa sign 8-bit excess-17 characteristic 3-bit normalized fraction 3-bit standard Implied binary point 0 1 1 63 Mantissa sign 64-bit standard 11-bit excess 103 charactstic 5-bit normalized fraction Normalized fraction - the fraction always starts with a nonzero bit. e.g. 0.01 x e would be normalized to 0.1 x e-1 1.01 x e would be normalized to 0.101 x e+1 Since the only nonzero bit is 1, it is usually omitted in all computers today. Thus, the 3-bit normalized fraction in reality has 4 bits. The exponent is represented in a biased form. If we take an m-bit exponent, there are m possible unsigned integer values. Re-label these numbers: 0 to m -1 - m-1 to m-1-1 by subtracting a constant value (or bias) of m-1 (or sometimes m-1-1). Ex. using m=3, the bias = 3-1 = 4. Thus the series 0,1,,3,4,5,6,7 becomes -4,-3,-,-1,0,1,,3. Therefore, the true exponent -4 is represented by 0 in the bias form and -3 by +1, etc. zero is represented by 0.0 x 0. Ex. if n = 1010.1111, we normalize it to 0.10101111 x 4. The true exponent is +4. Using the 3-bit standard and a bias of m-1-1 = 8-1 -1 = 17, the true exponent (+4) is stored as a biased exponent of 4+17 = 131, or 10000011 in binary. Thus we have 0 1 0 0 0 0 0 1 1 0 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Notice that the first 1 in the normalized fraction is omitted. The biased exponent representation is also called excess n, where n is m-1-1 (or m-1 )..10 Binary Coded Decimals (BCD).11 Character Codes (ASCII The American Standard Code for Information Interchange)