Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

ICS312 Set 2 Representation of Numbers and Characters.
HEXADECIMAL NUMBERS Code
COE 202: Digital Logic Design Signed Numbers
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Fixed-Point Arithmetics: Part I
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.

Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Two’s Complement 1.As an action: (Assume the starting value is 1011) 1.Flip the bits from the starting value => Add one to get the answer.
Review Binary Basic Conversion Binary Decimal
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
Introduction to Number Systems
Codes and number systems Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken ( ) and Harris & Harris (DDCA)
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Computer Systems 1 Fundamentals of Computing Negative Binary.
Binary numbers and arithmetic. ADDITION Addition (decimal)
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Simple Data Type Representation and conversion of numbers
Number Representations and Computer Arithmetic. CS 21a 9/23/02 Odds and Ends Slide 2 © Luis F. G. Sarmenta and John Paul Vergara, Ateneo de Manila University.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CMPE 325 Computer Architecture II Cem Ergün Eastern Mediterranean University Integer Representation and the ALU.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Data Representation - Part I. Representing Numbers Choosing an appropriate representation is a critical decision a computer designer has to make The chosen.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 29, 2004 Lecture Number: 26.
ICS312 Set 1 Representation of Numbers and Characters.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
Number Systems. Today Decimal Hexadecimal Binary –Unsigned Binary –1’s Complement Binary –2’s Complement Binary.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
INEL 4215: Computer Architecture and Organization Number Systems Signed numbers.
AEEE2031 Data Representation and Numbering Systems.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Digital Logic Lecture 3 Binary Arithmetic By Zyad Dwekat The Hashemite University Computer Engineering Department.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 8, 2004 Lecture Number: 7.
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.
ECE 3110: Introduction to Digital Systems Number Systems: signed numbers.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Computer Organization 1 Data Representation Negative Integers.
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Representing Positive and Negative Numbers
Design of Digital Circuits Reading: Binary Numbers
Addition and Subtraction
Negative Binary Numbers
Negative Binary Numbers
ECE 2110: Introduction to Digital Systems
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 6
Unit 18: Computational Thinking
Presentation transcript:

Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11= (3) 10 %100= (4) 10 %101= (5) 10 LSBMSB Nibble Byte word = 16 bits (2 bytes) long word = 32 bits (4 bytes) (double) %110= (6) 10 %111= (7) 10 %1000= (8) 10 %1001= (9) 10 %1010= (10) 10 %1011= (11) 10 %1100= (12) 10 %1101= (13) 10 %1110= (14) 10 %1111= (15) 10 %10000= (16) 10 %10001= (17) 10 %10010= (18) 10 %10011= (19) 10 %10100= (20) 10 : % = (153) 10 : © 2013 Stephen R. Platt

Digital Representations ME 4612 Hexidecimal (HEX) Representation Easier to work with than long strings of 1s and 0s 16 “digits” each representing 4 bits $0 =%0000 = (0) 10 $1 = %0001 = (1) 10 $2 = %0010 = (2) 10 $3 = %0011 = (3) 10 $4 = %0100 = (4) 10 $5 = %0101 = (5) 10 $6 = %0110 = (6) 10 $7 = %0111 = (7) 10 $8 =%1000 = (8) 10 $9 = %1001 = (9) 10 $A = %1010 = (10) 10 $B = %1011 = (11) 10 $C = %1100 = (12) 10 $D = %1101 = (13) 10 $E = %1110 = (14) 10 $F = %1111 = (15) 10 © 2013 Stephen R. Platt

Digital Representations ME 4613 Hex to Binary Conversion Each Hex digit represents 4 bits Simply convert each digit to its 4-bit value Example: Convert $DF3 to binary $DF3 = % © 2013 Stephen R. Platt

Digital Representations ME 4614 Binary to Hex Conversion Create groups of 4 bits (starting with LSB) Pad last group with zeros if needed Convert each group to corresponding Hex digit Example: Convert % to Hex % = % % = $345 © 2013 Stephen R. Platt

Digital Representations ME 4615 Fixed Precision Beware of overflow problems! Microprocessors limit numbers to a fixed number of bits: For example: What is the result of (assuming 8 bit precision)? 255 = % = $FF + 1 = % = $  % = $00 $F + 1 = 0, carry $F + 1 (carry) + 0 = 0, carry Carry out of MSB falls off the end because there is no place to put it! Final answer is WRONG because could not store carry bit. © 2013 Stephen R. Platt

Digital Representations ME 4616 Signed Integers What do we do about negative numbers? For straight binary we can represent 2 N (positive) numbers To handle positive and negative numbers, the sign is an extra piece of information that must be encoded. Two’s Complement is the most common representation Two’s Complement MSB becomes the SIGN bit (1 indicates a negative number) Can now represent signed integers -2 N-1 to +2 N-1 – 1 (e.g., -128 to 127) Algorithm #1: complement binary number and then add 1 Algorithm #2: start with LSB, copy bits up to and including the first 1, then invert all remaining bits Example: 14 = % = % Important Note: The computer generally does not know that a bit sequence represents a signed number. It is the programmer’s (i.e., your) responsibility! © 2013 Stephen R. Platt

Digital Representations ME 4617 Signed Integers Does arithmetic still work? Example: What is the sum of (-128) 10 + (127) 10 in binary representation? (Verify by converting the result to decimal representation.) Solution: (-128) 10 = % (127) 10 = % % (in two’s complement) MSB =1 tells you this is a negative number Complement and add 1 to get magnitude % % = % = (1) 10 Final result is (-1) 10, so life is good! © 2013 Stephen R. Platt

Digital Representations ME 4618 Two’s Complement Overflow What happens if we do (1) 10 + (127) 10 using two’s complement representation? (1) 10 = % (127) 10 = % % (in two’s complement) MSB =1 tells you this is a negative number Complement and add 1 to get magnitude % % = % = (128) 10 Final result is (-128) 10, so life is not so good! © 2013 Stephen R. Platt

Digital Representations ME 4619 Adding Precision (unsigned) What if we want to take an unsigned number and add bits to it? Just add zeros to the left! (128) 10 = $80(8 bits) = $0080(16 bits) = $ (32 bits) © 2013 Stephen R. Platt

Digital Representations ME Adding Precision (two’s complement) What if we want to take a two’s complement number and add bits to it? Take whatever the Sign bit is and extend it to the left. (127) 10 = $7F= % (8 bits) = $007F= % (16 bits) = $ F= %00………… (32 bits) (-128) 10 = $80 = % (8 bits) = $FF80 = % (16 bits) = $FFFFFF80 = %11……… (32 bits) This is called Sign Extension. © 2013 Stephen R. Platt

Digital Representations Integer Types int (or signed int) 16bits on MSP430 unsigned int 16bits on MSP430 char (or signed char) 8bits on MSP430 unsigned char 8bits on MSP430 © 2013 Stephen R. Platt ME 46111