Software Design and Development Storing Data Computing Science.

Slides:



Advertisements
Similar presentations
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Advertisements

CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Booth’s Algorithm.
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
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Number Representation Rizwan Rehman, CCS, DU. Convert a number from decimal to binary notation and vice versa. Understand the different representations.
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 Number Systems.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary Representation and Computer Arithmetic
The Binary Number System
Data Representation Number Systems.
Simple Data Type Representation and conversion of numbers
Binary Representation. Binary Representation for Numbers Assume 4-bit numbers 5 as an integer  as an integer  How? 5.0 as a real number  How?
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Computer Science 111 Fundamentals of Programming I Number Systems.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 22, 2004 Lecture Number: 24.
Computer Architecture
Shawlands Academy Higher Computing Data Representation.
Ch.3 - Computer Organization BIT Presentation 5.
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Chapter 3 Number Representation. Convert a number from decimal to binary notation and vice versa. Understand the different representations of an integer.
The Teacher CP4 Binary and all that… CP4 Revision.
COMP201 Computer Systems Floating Point Numbers. Floating Point Numbers  Representations considered so far have a limited range dependent on the number.
Fractions in Binary.
Floating Point in Binary 1.Place Value Chart:
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Binary Arithmetic.
Floating Point Binary A2 Computing OCR Module 2509.
Georgia Institute of Technology Introduction to Programming Part 3 Barb Ericson Georgia Institute of Technology May 2006.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
{ Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
 Computers are 2-state devices › Pulse – No pulse › On – Off  Represented by › 1 – 0  BINARY.
Starter Using two’s Complement form convert the following from Denary to Binary using 8 bits. Answer on mini whiteboard Using two’s.
OCR Computing OGAT Data Types. What OCR need you to know… Data Types a) Primitive data types, integer, real/floating point, character,
Floating Point Numbers
Nat 4/5 Computing Science Lesson 1: Binary
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Data Representation Covering… Binary addition / subtraction
Introduction To Computer Science
Number Systems and Binary Arithmetic
Recap Add these numbers together in binary
1.6) Storing Integer:.
Number Representation
How Computers Store Data
Computer Organization
Representation of real numbers
Floating Point Binary Part 1
OBJECTIVES After reading this chapter, the reader should be able to :
1.6) Storing Integer: 1.7) storing fraction:
Presentation transcript:

Software Design and Development Storing Data Computing Science

Learning Objectives By the end of this topic you will be able to: understand why computers store numbers as binary code;understand why computers store numbers as binary code; convert between binary and decimal; understand how computers store integers using two’s complement notation;understand how computers store integers using two’s complement notation; convert between a decimal integer and two’s complement notation; convert between a decimal integer and two’s complement notation; explain how computers store real numbers using floating point notation;explain how computers store real numbers using floating point notation;

Why Binary? Computers store data in billions of electronic switches called transistors Switches can either be on or off (two states) The easiest way to represent this is as a series of 0s and 1s

Human (Decimal) system Ten Thousands ThousandsHundredsTensUnits x x x x 1 = 1356

Binary system s64s32s16s8s4s2sUnits = 3

Binary system s64s32s16s8s4s2sUnits = 10

Binary system s64s32s16s8s4s2sUnits = 35

Binary system s64s32s16s8s4s2sUnits = 255 (2 8 = 256)

Converting Decimal to Binary Find the largest power of two which is less than the number to convert. Subtract it and repeat with the remainder.

Converting Decimal to Binary Convert 113 to binary 2 6 = = = = = = U

Positive Integers

Negative Integers (Using a sign-bit) There are two problems with this method 1000 and 0000 both mean zero Adding a positive number to a negative number gives the wrong answer

Why adding integers using the sign-bit method doesn’t work

Two’s Complement (8 bits) s64s32s16s8s4s2sUnits = 3 Make the most significant bit negative

Two’s Complement (8 bits) s64s32s16s8s4s2sUnits = -125

Two’s Complement (8 bits) s64s32s16s8s4s2sUnits = -118

Storing numbers using Two’s Complement (3 bits) In this example the 4s column is the sign bit

Addition now works and there is only one code for zero

Converting a negative decimal number 1.Establish the bit length required 2.Convert positive number to binary 3.Complement the binary number 4.Add 1

-3 (8 bits) 1.+3 = Complement Add Result

-15 (8 bits) = Complement Add Result

-35 (8 bits) = Complement Add Result

Real Numbers Real numbers are stored using Floating Point notation A Floating Point number takes up more memory than a two’s complement number and may be less accurate

Scientific Notation You will be familiar with how numbers like this are stored in the Decimal system: 1.34 X 10 3 Mantissa Exponent = 1340

Scientific Notation The exponent can be positive or negative 1.34 X Mantissa Exponent =

Floating Point Notation Computers use a similar system called floating point notation For example in binary is = x Exponent Mantissa The Exponent is a power of two stored in Two’s Complement notation because it can be positive or negative

Floating Point Notation The number of bits allocated to the Exponent determine the range of numbers you can store The number of bits allocated to the Mantissa determine the accuracy of the numbers you can store.

Range The exponent is an integer stored as a 2’s complement number 8 bits allocated to the exponent means it can represent a range of numbers between and

Accuracy The Mantissa is an integer stored as an unsigned (positive) number The larger the number of bits allocated to the mantissa, the more accurate the number will be

Floating Point Notation Floating Point Notation will always be a compromise between how accurately you can store a number and how wide a range of numbers you wish to store. For example if your floating point numbers as stored in 5 bytes (40 bits) you could allocate 32 bits to the mantissa and 8 bits to the exponent. If you wanted a more accurate number you would have to increase the number of bits allocated to the mantissa which would reduce the number available to the exponent