Review Two’s complement

Slides:



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

Number Bases Informatics INFO I101 February 9, 2004 John C. Paolillo, Instructor.
HEXADECIMAL NUMBERS Code
Company LOGO Edit your slogan here DKT 122/3 DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
1 Representing Numbers Using Bases Numbers in base 10 are called decimal numbers, they are composed of 10 numerals ( ספרות ) = 9* * *10.
Assembly Language and Computer Architecture Using C++ and Java

Assembly Language and Computer Architecture Using C++ and Java
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
Storage of Bits Computers represent information as patterns of bits
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Arithmetic and Logical Operations
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Digital Circuits. Analog and Digital Signals Noise margins in Logic Circuits VMVM.
Number Systems and Codes Discussion D4.1. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Mantıksal Tasarım – BBM231 M. Önder Efe
Number Systems Lecture 02.
B0011 Number Systems ENGR xD52 Eric VanWyk Fall 2012.
Topic 4 Computer Mathematics and Logic
Binary Addition Addition Rules: = = = = = carry 1 1 carry 1 Example 1: Example 2:
Arithmetic for Computers
Simple Data Type Representation and conversion of numbers
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Data Representation – Binary Numbers
Computers Organization & Assembly Language
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Digital Design: From Gates to Intelligent Machines
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
Logic and Digital System Design - CS 303
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
1 Homework Turn in HW2 tonight HW3 is on-line already Questions?
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
1.11, 1.12, 1.13, 1.14, 1.18, 1.20, 1.23, 1.24, 1.25, 1.32, 1.33.
COMPSCI 210 Semester Tutorial 1
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
CPU Internal memory I/O interface circuit System bus
ICS312 Set 9 Logic & Shift Instructions. Logic & Shift Instructions Logic and Shift Instructions can be used to change the bit values in an operand. The.
Number systems, Operations, and Codes
Positional Number Systems
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
AEEE2031 Data Representation and Numbering Systems.
1 Arithmetic and Logic Operations Patt and Patel Ch. 2 & 3.
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Number Systems and Bitwise Operation.
Number Systems Denary Base 10 Binary Base 2 Hexadecimal Base 16
Lecture 2 Binary Arithmetic Topics Terminology Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement August 26, 2003 CSCE 211.
69 Decimal (Base 10) Numbers n Positional system - each digit position has a value n 2534 = 2*1, * *10 + 4*1 n Alternate view: Digit position.
CCE Department – Faculty of engineering - Islamic University of Lebanon Chapter 6 Binary Arithmetic.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
BINARY SYSTEMS ENGR. KASHIF SHAHZAD 1. BINARY NUMBERS 1/2 Internally, information in digital systems is of binary form groups of bits (i.e. binary numbers)
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Memory unit terminology memory contains series of bits, grouped into addressable units word - unit of memory access and/or size of data registers, 16/32/64.
CHAPTER 3 BINARY NUMBER SYSTEM. Computers are electronic machines which operate using binary logic. These devices use two different values to represent.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
11001 / 101 , / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the.
CHAPTER 1 : INTRODUCTION
Number Systems and Bitwise Operation
University of Gujrat Department of Computer Science
Principles & Applications
King Fahd University of Petroleum and Minerals
Homework Homework Continue Reading K&R Chapter 2 Questions?
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Presentation transcript:

Review Two’s complement

Negate a Binary Number in 2C Negation means to find the corresponding negative number with the same absolute value (in decimal the Negation of 10 is –10) The method is the same whether you negate a positive to a negative or vice versa and doing it twice should give you the same result: -(-a) = a Method: Invert the binary number (“flip all bits”) Inverse (01001101) = 10110010 Add to the result binary 1 (append 0’s on the left) 10110010 + 1=10110010+00000001=10110011

Convert Decimal to 2C Decimal to Binary (word length k = 8): If positive: Fraction number into a sum of powers of 2 bin(13)=8+4+1=23+22+20 = 00001101 If Negative: Fraction the negated number and negate binary number (invert and add 1) bin(-13) = Negate(bin(13)) = Negate(00001101) = Invert(00001101)+00000001=11110010+00000001 = 11110011

Convert 2C to Decimal Binary to Decimal (word length k=8): If most significant bit (left most) is 0 the number is positive: Sum the powers of 2 Dec(00101101)=0*27 +0*26+1*25 +0*24 +1*23 +1*22 +0*21 +1*20 =1*128+0*64+1*32+0*16+1*8+1*4+0*2+1*0 =173 If most significant bit (left most) is 1 the number is negative, that means you can not just add the powers of 2 Find the decimal value of the negated binary number and negate it back in decimal (putting a – in front) Dec(10101101) = - (Dec(Negate(10101101)) = - (Dec(Invert(10101101)+0000001)) = - (Dec(01010010+0000001)) = - (Dec(01010011)) - now it is a positive number and we can sum the powers of 2! = -(64+16+2+1) = - 83

Operations on 2C Addition: bitwise including carry as in decimal Negation: Invert and add 1 Subtraction: Addition of Negated operand: A – B =A + (– B) Multiplication by 2: Shift left 00101101 * 2 = 01011010 Division by 2: Shift right 00101101 ÷ 2 = 00010110

Issues: Binary Numbers Signed Extension: Sometimes we are lazy and don’t write out all bits. In 2C you can only add 0’s to the left if the number is positive, otherwise you make a negative number positive: -3 = 1101 for k=4 = 11111101 for k=8 For negative number you have to add 1’sto the left! Overflow: If the result of an addition/subtraction is bigger than the biggest or smaller than the smallest possible number of word length k Can never happen if you add a positive and a negative number

Hexadecimal Numbers Decimal Hex Binary 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 Same principle as decimal and binary but with a base of 16 Number has a little x to the side: xF5 Motivation: Word size is either 32 or 64, that are very long binary numbers, in Hex you can save space: Conversion from Hex to binary is simple in blocks of 4(this works because 16=24): x5B2F = 0101 1011 0010 1111 To decimal (if positive): = 5*163 + 11*162 + 2*161 + 15*160 = 20480 + 2816 + 32 + 15 = 23343

LOGICAL OPERATORS A B AND 0 0 0 1 1 0 1 1 1 A B OR 0 0 0 1 1 1 0 1 1 0 0 0 1 1 0 1 1 1 A B OR 0 0 0 1 1 1 0 1 1 A B XOR 0 0 0 1 1 1 0 1 1 AND: is only 1 if all inputs are 1 OR: is 1 if any of the inputs is 1 XOR: is 1 if either input is 1 NOT: is the inverse (“flip the bit”) A NOT 1

Logic on Words and Multiple Input 00101101 AND 11101010 00101000 10011000 00001000 00101101 OR 11101010 11101111 10011000 11111111

Text Data: ASCII Code ASCII is a 7 bit encoding scheme for all keyboard symbols and some additional ones Digits: x30 to x39 Uppercase: x41 to x5A Lowercase: x61 to x7A Conversion: Table Question: How can you mathematically convert a lowercase letter into uppercase?