Fractions in Binary.

Slides:



Advertisements
Similar presentations
Scientific Notation.
Advertisements

1 IEEE Floating Point Revision Guide for Phase Test Week 5.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Floating Point Numbers
Booth’s Algorithm.
Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional.
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.
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
Floating Point Numbers
Binary numbers. 1 Humans count using decimal numbers (base 10) We use 10 units: 0, 1, 2, 3, 4, 5, 6, 7, 8 and (5.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Binary Numbers 1.Binary and Denary RecapBinary.
Binary Number Systems.
The Binary Number System
Scientific Notation.
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
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”
Scientific Notation. What is scientific notation? Scientific notation is a way of expressing really big numbers or really small numbers. It is most often.
 Scientific notation is a way of expressing really big numbers or really small numbers.  It is most often used in “scientific” calculations where the.
Data Representation - Part II. Characters A variable may not be a non-numerical type Character is the most common non- numerical type in a programming.
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.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
The Teacher CP4 Binary and all that… CP4 Revision.
Watch “Powers of 10” csu/powersof10/
Aim: How can we express a large or small number?
CSPP58001 Floating Point Numbers. CSPP58001 Floating vs. fixed point Floating point refers to a binary decimal representation where there is not a fixed.
Floating Point in Binary 1.Place Value Chart:
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Scientific Notation. Pages of notebook Essential question: How do I write small and large numbers using scientific notation? Objective: I can write.
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
Floating Point Binary A2 Computing OCR Module 2509.
Floating Point Numbers
SCIENTIFIC NOTATION Expressing a quantity as: a number between 1 and 10 multiplied by 10 to the appropriate power.
Scientific Notation By Jenny Erickson. What is scientific Notation? Scientific notation is a way of expressing really big numbers or really small numbers.
Scientific Notation What is scientific Notation? Scientific notation is a way of expressing really big numbers or really small numbers. It.
Scientific Notation. What is scientific notation Use of powers of 10 in writing a number is called scientific notation. Such number have the form M x.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.7 Instructor: Lin Chen Sept 2013.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
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.
Software Design and Development Storing Data Computing Science.
Starter Using two’s Complement form convert the following from Denary to Binary using 8 bits. Answer on mini whiteboard Using two’s.
Floating Point Numbers
Floating Point Representations
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Data Representation Covering… Binary addition / subtraction
Objectives Today: P4 Data Types – Floating Points P4 Variable Quiz P3 Iteration and Selection Practical Are you logged on? Then come around the table Unit.
Convert scientific notation to standard notation
Introduction To Computer Science
Recap Add these numbers together in binary
Scientific Notation.
Scientific Notation.
Scientific Notation.
Scientific Notation.
Scientific Notation.
Storing Negative Integers
Starter Using the fingers on only one hand, what is the highest number you can count to? Rules: You must start at 1 You must count sequentially (i.e.
Watch “Powers of 10”
Representation of real numbers
Normalised Floating Point Numbers
Scientific Notation.
Scientific Notation.
COMS 161 Introduction to Computing
Numbers with fractions Could be done in pure binary
Presentation transcript:

Fractions in Binary

Fractions Binary doesn’t just do integers (whole numbers) it can also be used for fractions though it isn’t as accurate as decimals in denary e.g. 136.75 could be expressed as 136 + 1/2 + 1/4 128 64 32 16 8 4 2 1 . 1/2 1/4 1/8 1/16 1 0 0 0 1 0 0 0 . 1 1 0 0 This is binary notation – the decimal point is in a fixed point

The problem Clearly with a limited number of places after the decimal point it is far less accurate as only a limited range of decimals can be displayed The number of extra places after the decimal point increase accuracy

Fixed point example 1 byte = 8 bits If 4 bits were assigned after the decimal Place (this does not take up any bits) 8 4 2 1 . 1/2 1/4 1/8 1/16 0 1 1 1 0 1 0 1

Task Look at the table on page 195 showing binary fractions Do questions 1-3 on page 196

So how do you represent all of the other decimals in binary? Floating point binary

Floating Point Binary In decimal, you can use scientific notation for really big numbers e.g. 1,2,0000,0000,0000 Would be 0.12 x 10 13 Exponent Which defines where to place the decimal point In this case move 13 places to the right Mantissa Which holds the digits

Floating Point Binary In binary, firstly bits are shared between the mantissa and the exponent In the example below, 2 bytes (16 bits) with 10 bits for the mantissa and 6 for the exponent Mantissa Exponent 0110100000 000011 = 0.1101 x 2 Sign bit 3 This is a sign bit – if positive i.e. 0 move the decimal point right, if negative i.e. 1 move the decimal point left There is always an imaginary decimal here

Floating Point Binary Mantissa Exponent 0110100000 000011 = 0.1101 x 2 = 110.1 = 6.5 in denary 3

Task Do Q4 on page196 Rules: Place the point between the sign bit and the first digit of the mantissa Convert the exponent to its decimal form (positive or negative) Move the point right if the exponent is positive or left if negative Convert the resulting binary number to denary

If the mantissa is negative Mantissa Exponent 1110100000 000011 1.1101 would become 1110.1 -8 4 2 1 . ½ 1 1 1 0 . 1 = -8+4+2+0.5 = -1.5 Negative sign bit Move three places right Negative leftmost bit

What if the mantissa and exponent are negative? Mantissa Exponent 1100000000 111110 1.1 -2 Move the point left and fill with 1’s as you do so: 1.111 -1+0.5+0.25+0.125 = -0.125

Task Do question 5 on page 197

Normalisation In order to get the most accurate representation possible with a given size of mantissa, no zeros should be put to the left of the most significant bit (not including the sign bit) E.g. in decimal: 0.034568x10 would be normalised to 0.34568x10 A binary number in normalised form will have the first bit of the mantissa not including the sign bit as a 1 9 8

To normalise a number in binary 0 000110101 000010 put in the binary point and convert the exponent to decimal: 0.000110101 Exponent 2 Move the number to the correct position and count the number of movements to the left to get the binary point before the first 1 0.110101000 required 3 left places Take 3 away from the exponent of 2: 2-3 = -1 Convert -1 back to binary 0 110101000 11111

To normalise a negative number in binary With a negative number, the most significant bit not including the sign bit will be a 0 Shift the number left until the first bit (not the sign bit) is a zero then adjust the exponent

To normalise a negative number in binary 1 111100100 000011 put in the binary point and convert the exponent to decimal: 1.111100100 Exponent 3 Move the number to the correct position and count the number of movements to the left to get the binary point before the first 0 1.001000000 required 4 left places Take 4 away from the exponent of 3: 4-3 = -1 Convert -1 back to binary 1.001000000 11111

Task Do question 6 and 7 on page 198 Read the hint on page 198 Do exercises on page 199