Binary Negative Integers.

Slides:



Advertisements
Similar presentations
Monika Gope Lecturer IICT, KUET
Advertisements

Fixed-point and floating-point numbers CS370 Fall 2003.
Nat 4/5 Computing Science Lesson 1: Binary
Data Storage and manipulation. Data Storage Computers store and manipulate data in the form of electronic pulses (high and Low voltages). This digitised.
A-Level Computing#BristolMet Session Objectives#9 express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal; describe and use two’s.
Lecture - 2 Number systems and computer data formats
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Chapter 2 : Number System
CHAPTER 2 Number Systems, Operations, and Codes
Floating Point Numbers
Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional.
Signed Numbers.
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
Floating Point Numbers
Data Representation in Computers
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 1 Overflow Signed binary is in fixed range -2 n-1  2 n-1 If the answer for addition/subtraction more than the.
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
Data Storage. SIGN AND MAGNITUDE Storing and representing numbers.
Binary Representation and Computer Arithmetic
Chapter 5 Data representation.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Simple Data Type Representation and conversion of numbers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Data Representation – Binary Numbers
Introduction to Number Representation F451 Year 10 Computing Binary Numbers Binary Numbers Sign/Magnitude Sign/Magnitude 2s Complement 2s Complement Binary.
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
Computer Math CPS120: Data Representation. Representing Data The computer knows the type of data stored in a particular location from the context in which.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
Binary Arithmetic & Data representation
COMPSCI 210 Semester Tutorial 1
Number Systems Spring Semester 2013Programming and Data Structure1.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Computer Systems Architecture Copyright © Genetic Computer School 2008 CSA 1- 0 Lesson 1 Number System.
The Teacher CP4 Binary and all that… CP4 Revision.
The Teacher CP4 Binary and all that… CP4 Revision.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
Computer Math CPS120: Lecture 3. Binary computers have storage units called binary digits or bits: Low Voltage = 0 High Voltage = 1 all bits have 0 or.
Data Representation, Number Systems and Base Conversions
CHAPTER 1 INTRODUCTION TO DIGITAL LOGIC
AEEE2031 Data Representation and Numbering Systems.
Number Systems & Operations
SAK Chapter 21 Chapter 2 : Number System 2.1 Decimal, Binary, Octal and Hexadecimal Numbers 2.2 Relation between binary number system with other.
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
1 Information Representation in Computer Lecture Nine.
Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16.
Computers and Numbers. Types of Numbers Computers store two different types of numbers: Whole Numbers AKA Integers (mathematics) AKA Fixed Point Numbers.
Floating Point Binary A2 Computing OCR Module 2509.
Computer Data Formats Microprocessor Course Electrical Engineering Department University of Indonesia.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
Digital Logic Design Lab 1,2 By Nora Alaqeel.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
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.
Floating Point Numbers
Fundamentals of Computer Science
CSCI 198: Lecture 4: Data Representation
CSCI 161: Lecture 4: Data Representation
Number Systems.
CS1010 Programming Methodology
BCD = Binary Coded Decimal
Presentation transcript:

Binary Negative Integers

Negative Integers Sign and magnitude One’s complement Two’s complement Binary Coded Decimal (BCD)

Sign and Magnitude The method used in decimal to represent negative numbers is sign and magnitude. - 25 Sign Magnitude/value This system is available in decimal where: 1 ≡ negative sign

Sign and Magnitude The method is as follows: Convert the value or magnitude to binary and represent using eight or ten bits or as you are instructed Change the leftmost bit to 1 if the number is negative

Example: Represent the following decimal as binary, using sign and magnitude: NEGATIVE 1010 NEGATIVE 2510

-10 to Binary using 8 bit Sign and Magnitude Convert 10 to binary 1010 Use 8 bits to represent 00001010 Change to negative: 10001010 -1010=100010102 2 10 Remainder 5 1

-25 to Binary using 8 bit Sign and Magnitude Convert 25 to binary 11001 Use 8 bits to represent 00011001 Change to negative: 10011001 -2510=100110012 2 25 Remainder 12 1 6 3

One’s Complement The method is as follows: Convert the value or magnitude to binary and represent using eight or ten bits or as you are instructed Find the complement by changing all the 0’s to 1’s and all the 1’s to 0’s

Example: Represent the following decimal as binary, using ONE’S COMPLEMENT: NEGATIVE 1010 NEGATIVE 2510

-25 to Binary using 8 bit One’s Complement Convert 25 to binary 11001 Use 8 bits to represent 00011001 Change to negative: 1 0 and; 0 1 11100110 -2510=111001102 2 25 Remainder 12 1 6 3

Two’s Complement The method is as follows: Convert the value or magnitude to binary and represent using eight or ten bits or as you are instructed Find the One’s complement by changing all the 0’s to 1’s and all the 1’s to 0’s Add one to the new value

Example: Represent the following decimal as binary, using TWO’S COMPLEMENT: NEGATIVE 1010 NEGATIVE 2510

-25 to Binary using 8 bit Two’s Complement Convert 25 to binary 11001 Use 8 bits to represent 00011001 Find one’s complement 11100110 Add one to the answer 11100110+1 -2510=111001112 2 25 Remainder 12 1 6 3 1 +

Binary Coded Decimal B.C.D.

Format Each digit is converted separately using four (4) bits each. 25 Remainder 1 2= 0010 25 2 5 Remainder 1 5=0101 0010 0101

Format Decimal positioning is kept 25 = 0010 0101 2 10

Negative BCD Use Sign and Magnitude where the signs are: + Positive = 1110 2 - Negative = 1111 2

Positive and Negative +25 = 11100010 0101 2 -25 = 11110010 0101 2

Convert the following numbers from decimal to binary using BCD format: Steps: Convert each digit to binary Write sign (if necessary) Write answer in decimal order Convert the following numbers from decimal to binary using BCD format: 10 250 43 11 54 -10 +250 -43 +11 -54

Binary Real Numbers

Real Numbers Real numbers are numbers containing fractions. There are two ways real numbers are represented in binary. They are: Fixed-point numbers Floating-point numbers

Fixed-point Numbers Decide the number of places after the point because the point is not stored among the digits. Convert the whole number to binary Convert the fraction to binary: Multiply the fraction by two and record the any resulting whole number Repeat until you get the set amount of places after the point

Fixed-point Numbers Convert 4.210 to binary with 4 places after the point. The answer is therefore:10000112 2 4 R 1 =100 0.2 x 2 = 0.4 0.4 x 2 0.8 0.8 x 2 1.6 0.6 x 2 1.2 =0011

Floating-point Numbers The number of places after the point varies. Data is represented in the following parts: A sign A fractional part (example 0.345) or mantissa The base An exponent

Standard Form Change to standard form: 345 -45.6

Floating-point Numbers Decimal Example: This is equal to writing a number in standard form 3 345 = 0.345 x 10 Exponent Sign Mantissa base 2 -45.6 = -0.456 x 10

Floating-point Numbers Binary Example: Binary number 11111010 The mantissa is a binary fraction The sign bit : 1 for negative and 0 for positive This exponent uses sign and magnitude 1 111 1010 Sign Exponent Mantissa

Floating-point Numbers IEEE Standard uses 32 and 64bits, but for simplicity we will use only 8 bits as follows: The sign – 1 bit 1 means negative; 0 means positive The Exponent – 3 bits Sign and magnitude. Leftmost bit is the sign The Mantissa – 4 bits A fraction

From Decimal: 3¾ Convert the decimal to binary (maintain the whole and fraction parts). Normalise the mantissa Convert the resulting exponent Insert the sign bit Write the number in SEM format 3 ¾ to binary retaining decimal format: 11.11 Normalised mantissa as if in standard form: .1111x22 The exponent : 2 = 011 The number is positive, so the sign = 0 RESULT:0 011 11112

Let us Calculate: Binary Example: 111110102 The mantissa : 0.625 The sign bit : - (negative) The exponent : -3 RESULT: - 0.1010 X 2-3 2-1 2-2 2-3 2-4 1 .5 0.125 1 111 1010 Sign Exponent Mantissa - -3 0.625 = 0.5 + 0.125

Let us Calculate: Binary Example: 111110102 The mantissa is: 0.625 The sign bit : - (negative) The exponent : -3 RESULT: - 0.1010 X 2-3 = -0 0 0 0.1 0 1 0 =-0.00012 = - 0.062510

Characters ASCII (American Standard Code of Information Interchange) EBCDIC (Extended Binary Coded Decimal Interchange Code

Parity Bit To maintain data integrity a special signal bit is sometimes used. This is a parity bit. Instead of the regular eight bits that make up the byte, nine bits are used. If he number of “1” bits is odd then the parity is set to 1 so that the number of 1”s is always even If the number of “1” bits is even the parity is set to “0”.

The END