Binary Fractions.

Slides:



Advertisements
Similar presentations
Binary Number Systems.
Advertisements

Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Chapter 1.7 Storing Fractions. Excess Notation, continued… In this notation, "m" indicates the total number of bits. For us (working with 8 bits), it.
Floating Point Numbers
Floating Point Numbers. CMPE12cGabriel Hugh Elkaim 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or.
Floating Point Numbers. CMPE12cCyrus Bazeghi 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or 2 64.
Chapter 5 Floating Point Numbers. Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer.
Signed Numbers.
Floating Point Numbers
Floating Point Numbers
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Lecture 8 Floating point format
Binary Number Systems.
Binary Representation and Computer Arithmetic
The Binary Number System
Data Representation Number Systems.
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Computer Arithmetic Nizamettin AYDIN
Factional Values What is 0.75 in binary?. How could we represent fractions? In decimal: – As fractions : 1/5.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
Convert 33km to centimeters (cm) Show all steps and work!! (4x10 12 ) x (3x10 14 ) = ? 8 x  What is the difference between the measurement 14m and.
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
Computer Science Engineering B.E.(4 th sem) c omputer system organization Topic-Floating and decimal arithmetic S ubmitted to– Prof. Shweta Agrawal Submitted.
Binary Fractions. Fractions A radix separates the integer part from the fraction part of a number Columns to the right of the radix have negative.
Physics Day 5 Objectives SWBAT do exponential math Understand factors of 10 Agenda Do Now Notes Worksheet HW2 due tonight HW3 Thursday.
CSC 221 Computer Organization and Assembly Language
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
ITEC 1011 Introduction to Information Technologies 4. Floating Point Numbers Chapt. 5.
Introduction to Number System
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Floating Point in Binary 1.Place Value Chart:
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.7 Instructor: Lin Chen Sept 2013.
Lecture 6: Floating Point Number Representation Information Representation: Floating Point Number Representation Lecture # 7.
Learning Objectives 3.3.1f - Describe the nature and uses of floating point form 3.3.1h - Convert a real number to floating point form Learn how to normalise.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Numbers
Nat 4/5 Computing Science Lesson 1: Binary
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Dr. Clincy Professor of CS
Scientific Notation.
Introduction To Computer Science
Dr. Clincy Professor of CS
Floating Point Numbers: x 10-18
Floating Point Number system corresponding to the decimal notation
William Stallings Computer Organization and Architecture 7th Edition
Data Structures Mohammed Thajeel To the second year students
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Notes: Scientific Notation
Data Representation Data Types Complements Fixed Point Representation
Dr. Clincy Professor of CS
Scientific Notation.
Dr. Clincy Professor of CS
ECEG-3202 Computer Architecture and Organization
Chapter 8 Computer Arithmetic
Storing Integers and Fractions
Representation of real numbers
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
COMS 161 Introduction to Computing
Chapter3 Fixed Point Representation
Scientific Notation.
Numbers with fractions Could be done in pure binary
1.6) Storing Integer: 1.7) storing fraction:
Presentation transcript:

Binary Fractions

Fractions A radix separates the integer part from the fraction part of a number. 101.101 Columns to the right of the radix have negative powers of 2.

Fractions 22 21 20 . 2-1 2-2 2-3

Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 ½ ¼ ⅛

Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 ½ ¼ ⅛

Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 ½ ¼ ⅛ +

Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 ½ ¼ ⅛ + 5⅝

Fractions Another way to assess the fraction: 4 2 1 . ½ ¼ ⅛ 1 0 1 . 1 0 1 Just as this is 5

Fractions Another way to assess the fraction: 4 2 1 . ½ ¼ ⅛ 1 0 1 . 1 0 1 Just as this is 5 so is this!

Fractions Another way to assess the fraction: 4 2 1 . ½ ¼ ⅛ 1 0 1 . 1 0 1 Just as this is 5 so is this Except it’s not 5 ones. It’s 5 eighths.

Fractions Another way to assess the fraction: 4 2 1 . ½ ¼ ⅛ 1 0 1 . 1 0 1 Just as this is 5 so is this Except it’s not 5 ones. It’s 5 eighths.

Fractions But there’s no dot (.) in Binary! We need to explore a method for storing fractions without inventing another symbol.

Scientific Notation a × 10b 1 ≤ |a| < 10 Very large and very small numbers are often represented such that their orders of magnitude can be compared. The basic concept is an exponential notation using powers of 10. a × 10b Where b is an integer, and a is a real number such that: 1 ≤ |a| < 10

Scientific Notation - examples An electron's mass is about 0.00000000000000000000000000000091093826 kg. In scientific notation, this is written: 9.1093826×10−31 kg.

Scientific Notation - examples An electron's mass is about 0.00000000000000000000000000000091093826 kg. In scientific notation, this is written: 9.1093826×10−31 kg.

Scientific Notation - examples The Earth's mass is about 5,973,600,000,000,000,000,000,000 kg. In scientific notation, this is written: 5.9736×1024 kg.

Scientific Notation - examples The Earth's mass is about 5,973,600,000,000,000,000,000,000 kg. In scientific notation, this is written: 5.9736×1024 kg.

E Notation To allow values like this to be expressed on calculators and early terminals ‘× 10b’ was replaced by ‘Eb’ So 9.1093826×10−31 becomes 9.1093826E−31 And 5.9736×1024 becomes 5.9736E+24

E Notation The ‘a’ part of the number is called the mantissa or significand. The ‘Eb’ part is called the exponent. Since exponents could also be negative, they would typically have a sign as well.

Floating Point Storage In floating point notation the bit pattern is divided into 3 components: Sign – 1 bit (0 for +, 1 for -) Exponent – stored in Excess notation Mantissa – must begin with 1

Floating Point Storage In floating point notation the bit pattern is divided into 3 components: Sign – 1 bit (0 for +, 1 for -) Exponent – stored in Excess notation Mantissa – must begin with 1

Floating Point Storage In floating point notation the bit pattern is divided into 3 components: Sign – 1 bit (0 for +, 1 for -) Exponent – stored in Excess notation Mantissa – must begin with 1

Floating Point Storage In floating point notation the bit pattern is divided into 3 components: Sign – 1 bit (0 for +, 1 for -) Exponent – stored in Excess notation Mantissa – must begin with 1

Mantissa Assumes a radix point immediately left of the first digit. The exponent will determine how far, and in which direction to move the radix.

An example in 8 bits If the following pattern stores a floating point value, what is it? 01101001

An example in 8 bits If the following pattern stores a floating point value, what is it? 01101001 Separate it into its components:

An example in 8 bits If the following pattern stores a floating point value, what is it? 01101001 Separate it into its components: sign exponent mantissa

An example in 8 bits If the following pattern stores a floating point value, what is it? 0 110 1001 Separate it into its components: sign exponent mantissa

An example in 8 bits 0 110 1001 A sign bit of 0 means the number is…?

An example in 8 bits 0 110 1001 A sign bit of 0 means the number is positive. 110 in Excess Notation converts to …?

An example in 8 bits 0 110 1001 A sign bit of 0 means the number is positive. 110 in Excess Notation converts to +2. Place the radix in the mantissa …

An example in 8 bits 0 110 1001 A sign bit of 0 means the number is positive. 110 in Excess Notation converts to +2. Place the radix in the mantissa .1001 Put it all together …

An example in 8 bits 0 110 1001 A sign bit of 0 means the number is positive. 110 in Excess Notation converts to +2. Place the radix in the mantissa .1001 Put it all together … + .1001 * 22

An example in 8 bits + .1001 * 22 9/16 * 4 = 36/16 9/16 * 4 = 9/4 As we’ve seen: + .1001 * 22 the mantissa can be understood as 9, in the sixteenths column. Of course, 22 is 4, so we need to solve 9/16 * 4. 9/16 * 4 = 36/16 9/16 * 4 = 9/4 = 2 4/16 = 2 1/4

Alternatively + .1001 * 22 Multiplying a binary number by 2 shifts the bits left (moves the radix to the right) one position. So the exponent +2 tells us to shift the radix 2 positions right. + 10.01 = 2¼

Normal Form The rule of Normal Form guarantees a unique mapping of patterns onto values.

Normal Form Consider the following 8-bit pattern in Normal Form: 0 100 1000 .1000 0 101 0100 1 .0100 0 110 0010 2 .0010 0 111 0001 3 .0001

Normal Form The exponent represents 0 so the radix is moved 0 positions. 0 100 1000 .1000 0 101 0100 1 .0100 0 110 0010 2 .0010 0 111 0001 3 .0001

Normal Form The exponent represents 0 so the radix is moved 0 positions. 0 100 1000 .1000 0 101 0100 1 .0100 0 110 0010 2 .0010 0 111 0001 3 .0001

Normal Form Now consider this pattern, which is NOT in Normal Form. 0 100 1000 .1000 0 101 0100 1 .0100 0 110 0010 2 .0010 0 111 0001 3 .0001

Normal Form The exponent represents +1 so the radix is moved 1 position to the right. 0 100 1000 .1000 0 101 0100 1 .0100 0 110 0010 2 .0010 0 111 0001 3 .0001

Normal Form The exponent represents +1 so the radix is moved 1 position to the right. 0 100 1000 .1000 0 101 0100 1 .0100 0 110 0010 2 .0010 0 111 0001 3 .0001

Normal Form But this is the same result as the first example! 0 100 1000 .1000 0 101 0100 1 .0100 0 110 0010 2 .0010 0 111 0001 3 .0001

Normal Form In fact there are MANY possible ways to represent the same value: 0 100 1000 .1000 0 101 0100 1 .0100 0 110 0010 2 .0010 0 111 0001 3 .0001

Normal Form The first bit of the mantissa must be 1 to prevent multiple representations of the same value. 0 100 1000 .1000 0 101 0100 1 .0100 0 110 0010 2 .0010 0 111 0001 3 .0001