Number Bases Informatics INFO I101 February 9, 2004 John C. Paolillo, Instructor.

Slides:



Advertisements
Similar presentations
Combinational Circuits
Advertisements

EE1A2 Microprocessor Systems & Digital Logic Part I Digital Electronic System Design Dr. T. Collins.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Assembly Language and Computer Architecture Using C++ and Java
Assembly Language and Computer Architecture Using C++ and Java
Design of Arithmetic Circuits – Adders, Subtractors, BCD adders
1 CSE-221 Digital Logic Design (DLD) Lecture-1: Digital Systems & Number Systems.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Part 2: DESIGN CIRCUIT. LOGIC CIRCUIT DESIGN x y z F F = x + y’z x y z F Truth Table Boolean Function.
Logic Gates Combinational Circuits
Mantıksal Tasarım – BBM231 M. Önder Efe
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
Binary Representation and Computer Arithmetic
Dr. Bernard Chen Ph.D. University of Central Arkansas
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Simple Data Type Representation and conversion of numbers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Numbers and number systems
Numbering systems.
Copyright © Cengage Learning. All rights reserved. CHAPTER 2 THE LOGIC OF COMPOUND STATEMENTS THE LOGIC OF COMPOUND STATEMENTS.
Numeral Systems Subjects: Numeral System Positional systems Decimal
Computers Organization & Assembly Language
Binary Numbers.
Chapter 6 Digital Arithmetic: Operations and Circuits ECE 221 Intro
Logic Gates II Informatics INFO I101 February 5, 2003 John C. Paolillo, Instructor.
Basic Arithmetic (adding and subtracting)
Logic and Digital System Design - CS 303
IT253: Computer Organization
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
1 DLD Lecture 18 Recap. 2 Recap °Number System/Inter-conversion, Complements °Boolean Algebra °More Logic Functions: NAND, NOR, XOR °Minimization with.
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
CPU Internal memory I/O interface circuit System bus
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
Operations on Bits Arithmetic Operations Logic Operations
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
Logic Gates Informatics INFO I101 February 3, 2003 John C. Paolillo, Instructor.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
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.
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
Introduction To Number Systems Binary System M. AL-Towaileb1.
Chapter 1: Binary Systems
1 Fundamentals of Computer Science Combinational Circuits.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Number Representation and Arithmetic Circuits
Two’s and one’s complement arithmetic CLOCK ARITHMETIC.
Number Representation (Part 2) Computer Architecture (Fall 2006)
CPS120: Introduction to Computer Science Computer Math: Addition and Subtraction.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
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)
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.
Chapter 6. Digital Arithmetic: Operations and Circuits
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Prepared By: Norakmar Binti Mohd Nadzari CHAPTER 2 ARITHMETIC AND LOGIC UNIT.
Cosc 2150: Computer Organization
Digital Systems and Number Systems
Fundamentals & Ethics of Information Systems IS 201
University of Gujrat Department of Computer Science
Copyright © Cengage Learning. All rights reserved.
Arithmetic Circuits.
Presentation transcript:

Number Bases Informatics INFO I101 February 9, 2004 John C. Paolillo, Instructor

Items for Today Last week –Digital logic, Boolean algebra, and circuits –Logic gates and truth tables This Week –Numbers and bases –Working with binary

Number Base Systems

The Format of a Base System ##### … ##### … b4b4 b3b3 b2b2 b1b1 b0b0 … b -1 b -2 b -3 b -4 b -5 … The number represented is the sum of all the products of the digit values and their respective place values

Common Bases Decimal (Base 10) Binary (Base 2) Octal (Base 8) Hexadecimal (Base 16)

Conversion to Base 10 Identify each of the places in the new number base. These will correspond to the powers of the base, for example, with base 2, they are 1, 2, 4, 8, 16, 32, etc. Multiply the value for each place by the value of the digit appearing there; Add the results up, and you have the result in decimal Note that if you divide and add correctly, you can reverse this procedure to convert decimal into another base. It’s harder, because you’re not used to using the appropriate addition and multiplication tables.

Try out these examples What is Base 2 in decimal? 1      1 = 19 What is 121 Base 8 in decimal? 1    1 = 81 What is 247 Base 10 in Binary? Here it helps to have a different procedure…

Converting to Binary What we’re converting

Octal — base 8 Sixteen digits: 0, 1, 2, 3, 4, 5, 6, 7 7 = 111 two = 7 eight Octal values are usually not specially indicated Unix example:chmod 666 myfile.html

Octal Digits Octal Binary Decimal

Octal Tips each octal digit corresponds to three binary digits (bits) convert binary to octal by parsing each group of three bits into one octal digit convert octal to binary by translating each digit into three bits Examples: 764 eight = two two = 335 eight

Hexadecimal — base 16 Sixteen digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F 15 = 1111 two = F sixteen Hexadecimal (“hex”) values are usually indicated by a preceding base marker HTML: #FFFFFF JavaScript, C: 0xF1AD

Hexadecimal Digits Hex A B C D E F Binary Decimal

Hexadecimal Tips each hex digit corresponds to four binary digits (bits) convert binary to hex by parsing each group of four bits into one hex digit convert hex to binary by translating each digit into four bits Two hex digits make up one byte, a very common unit of memory

IP Numbers IP = “Internet Protocol” dhcp-Memorial– memorial.indiana.edu IP Number Host Name A Domain Name Server (DNS) has a database that matches IP and host name

The IP Number Four Fields in each field This is really base 256, but we use decimal numbers in each digit Net Subnet Node

Binary Addition

Adding in Binary Zero plus any other values leaves that value Identity value for addition No carry is generated One plus one leaves zero and causes a carry (one) to the next digit Each successive digit must accept the carry from the previous

Try these calculations Base Base Base Base Base Base Base 2  Base Base 2  Base Base 2  Base 2

Addition: Truth Tables CI 0 1 A A B B SCO S S

Addition: Half Adder S A B XOR C The half adder sends a carry, but can’t accept one So we need another for the carry bit 

Addition in Binary Two half-adders gives us a full adder –two inputs plus carry Adders are cascaded to permit adding binary numbers –Eight adders allows adding ( ) + ( ) in binary numbers –Overflow can happen ( ) Binary adders are used to do other computations as well...

Subtraction Complement Representations

Subtraction – –0100 Subtraction is asymmetrical That makes it harder We have to borrow sometimes 827 Minuend –223 Subtrahend =604 Difference/remainder

When Subtraction is Easy 456 – – Subtraction is easy if you don’t have to borrow –i.e. if all the digits of the minuend are greater than (or equal to) all those of the subtrahend This will always be true if the minuend is all 9’s: 999, or , or etc.

Using Easy Subtraction Subtract the subtrahend from 999 (or whatever we need) (easy) Add the result to the minuend (ordinary addition) Add 1 (easy) Subtract 1000 (drop highest digit) Difference = Minuend – Subtrahend + 1 – 1000 This works for binary as well as decimal

Easy Subtraction in Binary Subtract the subtrahend from 111 (or whatever we need) (easy) Add the result to the minuend (ordinary addition) Add 1 (easy) Subtract 1000 (drop highest digit) Difference = Minuend – Subtrahend + 1 – 1000

Binary Subtraction Example – ????????? – This is the same as inverting each bit – Regular addition Add one Now drop the highest bit (easy: it’s out of range)

Subtraction Procedure Invert each bit Regular addition Add one Now drop the highest bit (easy: it’s out of range) Each of these steps is a simple operation we can perform using our logic circuits Bitwise XOR Cascaded Adders Add carry bit Drop the highest bit ( it overflows)

Negative Numbers Invert each bit Add one These steps make the negative of a number in twos-complement notation Twos complements can be added to other numbers normally Positive numbers cannot use the highest bit (the sign bit) This is the normal representation of negative numbers in binary

Negative Numbers in Binary etc – – – – – – – – – –10 etc.

Representations The number representation you use (encoding) affects the way you need to do arithmetic (procedure) This is true of all codes: encoding (representation) affects procedure (algorithm) Good binary codes make use of properties of binary numbers and digital logic

A problem A computer program adds 20,000 and 20,000 and instead of 40,000, it reports – 25,566 No errors in encoding, decoding or addition How? Because the result is a negative number in twos-complement notation (highest bit = sign bit)

How it works 20,000 base ten is binary Highest bit is set, so number is negative in twos complement notation: subtract one and invert to display – 1 = = 25,566

Bottom Line Representations themselves, as we use them, have limits. Interpretation depends on context two procedures (encoding/decoding and addition) may be in and of themselves correct, but conflict in their application to specific examples

MER has landed