The number systems of Computer Science

Slides:



Advertisements
Similar presentations
ICS312 Set 2 Representation of Numbers and Characters.
Advertisements

Chapter 2 : Number System
Digital Fundamentals Floyd Chapter 2 Tenth Edition
1 Number Systems Patt and Patel Ch A Brief History of Numbers From Gonick, Cartoon Guide to Computer Science.
Assembly Language and Computer Architecture Using C++ and Java
CMPE12cGabriel Hugh Elkaim 1 Number Systems. CMPE12cGabriel Hugh Elkaim 2 A Brief History of Numbers From Gonick, Cartoon Guide to Computer Science.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Data Representation in Computers
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
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.
CS105 INTRODUCTION TO COMPUTER CONCEPTS BINARY VALUES & NUMBER SYSTEMS Instructor: Cuong (Charlie) Pham.
Numeral Systems Subjects: Numeral System Positional systems Decimal
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Digital Systems and Logic Design
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
IT253: Computer Organization
Chapter 3 Data Representation
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.
ICS312 Set 1 Representation of Numbers and Characters.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Chapter 2 Binary Values and Number Systems. 2 2 Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645,
Computer Systems Architecture Copyright © Genetic Computer School 2008 CSA 1- 0 Lesson 1 Number System.
CMPE12c Fall 03Cyrus BazeghiCMPE12c Fall 03Cyrus Bazeghi 1 Number Systems.
CCE-EDUSAT SESSION FOR COMPUTER FUNDAMENTALS Date: Session III Topic: Number Systems Faculty: Anita Kanavalli Department of CSE M S Ramaiah.
Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in other bases.
Number systems, Operations, and Codes
Binary Values and Number Systems
CMSC 104, Lecture 051 Binary / Hex Binary and Hex The number systems of Computer Science.
Positional Notation 642 in base 10 positional notation is:
Topic 1 – Number Systems. What is a Number System? A number system consists of an ordered set of symbols (digits) with relations defined for addition,
CISC1100: Binary Numbers Fall 2014, Dr. Zhang 1. Numeral System 2  A way for expressing numbers, using symbols in a consistent manner.  " 11 " can be.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Data Representation Conversion 24/04/2017.
Data Representation, Number Systems and Base Conversions
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Number Systems. Prehistory Unary, or marks: / /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better,
Number Systems Denary Base 10 Binary Base 2 Hexadecimal Base 16
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor DKT 122/3 - DIGITAL SYSTEM I Chapter.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Chapter 2 Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in.
Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture Logic Design: Part 1.
CHAPTER 3: Number Systems
CMSC 1041 Binary / Hex Binary and Hex The number systems of Computer Science.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Number Systems. ASCII – American Standard Code for Information Interchange – Standard encoding scheme used to represent characters in binary format on.
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.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
CS2100 Computer Organisation
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 : INTRODUCTION
Chapter 3 Data Representation
Number System conversions
University of Gujrat Department of Computer Science
CS1010 Programming Methodology
BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.
Numbering System TODAY AND TOMORROW 11th Edition
Binary / Hex Binary and Hex The number systems of Computer Science.
Data Representation Conversion 05/12/2018.
Chapter Four Data Representation in Computers By Bezawit E.
CHAPTER 69 NUMBER SYSTEMS AND CODES
Presentation transcript:

The number systems of Computer Science Binary & Hex The number systems of Computer Science

What you will learn Decimal Binary Hexadecimal Arithmetic Converting between number bases Counting 2’s Compliment

Number Systems Prehistory Unary, or marks: / /////// = 7 /////// + ////// = ///////////// Babylonian (Mesopotamia) around 2000 BC Used 60 numerical symbols – sexadecimal. Used to measure time 5; 25, 30 = 5hr 25min 30 secs. Was positional based by had no concept of zero. 5,4560 = 5 x 60 + 45 x 1 = 34510 Roman Numerals: (non positional, no concept of zero) VII + V = VVII = XII MCMXCIX = 1999 MCMXCVIIII = 1999 MCMLXXXXVIIII = 1999 MDCCCCLXXXXVIIII = 1999

Quote from Pierre Simon Laplace “The ingenious method of expressing every possible number using a set of ten symbols (each symbol having a place value and an absolute value) emerged in India. The idea seems so simple nowadays that its significance and profound importance is no longer appreciated. Its simplicity lies in the way it facilitated calculation and placed arithmetic foremost amongst useful inventions. the importance of this invention is more readily appreciated when one considers that it was beyond the two greatest men of Antiquity, Archimedes and Apollonius. “

Arabic/Indian Numerals (Decimal) Better, Arabic/Indian based Numerals: 7 + 5 = 12 = 1 x 10 + 2 345 is really 3 x 100 + 4 x 10 + 5 x 1 3 x 102 + 4 x 101 + 5 x 100 3 is the most significant symbol (carries the most weight) 5 is the least significant symbol (carries the least weight) Digits (or symbols) allowed: 0-9 Base (or radix): 10

Try multiplication in (non-positional) Roman numerals(!): XXXIII (33 in decimal) XII (12 in decimal) --------- XXXIII CCCXXX ----------- CCCXXXXXXXXXIIIIII CCCLXXXXVI CCCXCVI = 396 The Babylonians wouldn’t have had this problem.

There are many ways to “represent” a number Representation does not affect computation result LIX + XXXIII = LXXXXII (Roman) 59 + 33 = 92 (Decimal) Representation affects difficulty of computing results No concept of “Zero” Computers need a representation that works with fast electronic circuits

What is the base ? The decimal numbering system is also known as base 10. The values of the positions are calculated by taking 10 to some power. Why is the base 10 for decimal numbers ? Because we use 10 digits. The digits 0 through 9.

Main Memory Original computers used holes/no hole to represent two state, 1/0. Modern computers use transistor on/off translates to values 1/0 Requires use of Binary number system

Binary: positional numbers work great with 2-state devices Digits (symbols) allowed: 0, 1 Binary Digits, or bits Base (radix): 2 10012 is really 1 x 23 + 0 x 22 + 0 X 21 + 1 X 20 910 110002 is really ? Computers usually multiply Arabic numerals by converting to binary, multiplying and converting back for display

Counting in Binary Binary 1 10 11 100 101 110 111 Decimal equivalent 1 1 10 11 100 101 110 111 Decimal equivalent 1 2 3 4 5 6 7

Decimal to Binary Divide decimal value by 2 until the value is 0 E.g. 47 /2 = 23 Remainder 1 23/2 = 11 Remainder 1 11/2 = 5 Remainder 1 5/2 = 2 Remainder 1 2/2 = 1 Remainder 0 1/2 = 0 Remainder 1 Read from the bottom up Ans: 101111

Binary to Decimal 1 0 0 0 0 0 1 1 X 20 = 1 26 25 24 23 22 21 20 0 X 21 = 0 0 X 22 = 0 20 = 1 24 = 16 0 X 23 = 0 21 = 2 25 = 32 0 X 24 = 0 22 = 4 26 = 64 0 X 25 = 0 23 = 8 1 X 26 = 64 65

Binary to Decimal (alternative) Converting the binary 100101 to 37 Multiply running total by two, add in next digit. Repeat for all digits.

Some buzz words Single Binary Digit =Bit 4 bits = nibble 8 bits = byte 16 bits = word 32 bits = longword 2 nibbles = 1 byte 2 bytes = 1 word The word size depends on the processor used, above is shown the word size for the 68000

Addition of Binary Numbers Examples: 1 0 0 1 0 0 0 1 1 1 0 0 + 0 1 1 0 + 1 0 0 1 + 0 1 0 1 1 1 1 1 1 0 1 0 1 0 0 0 1 Carry a one

Addition (large numbers) Example showing larger numbers: 1 0 1 0 0 0 1 1 1 0 1 1 0 0 0 1 + 0 1 1 1 0 1 0 0 0 0 0 1 1 0 0 1 1 0 0 0 1 0 1 1 1 1 1 0 0 1 0 1 0

Working with large numbers 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 Humans can’t work well with binary numbers. We will make errors. Shorthand for binary that’s easier for us to work with - Hexadecimal

Hexadecimal Binary 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 Hex 5 0 9 7 Written: 509716

What is Hexadecimal really ? Binary 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 Hex 5 0 9 7 A number expressed in base 16. It’s easy to convert binary to hex and hex to binary because 16 is 24.

Counting in Hex Binary Hex Binary Hex 0 0 0 0 0 1 0 0 0 8 0 0 0 0 0 1 0 0 0 8 0 0 0 1 1 1 0 0 1 9 0 0 1 0 2 1 0 1 0 A 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D 0 1 1 0 6 1 1 1 0 E 0 1 1 1 7 1 1 1 1 F

Decimal to Hex Repeat dividing by 16 and noting the remainder until the quotient = 0 E.g. 54401d to Hex 54401/16 = 3400 Remainder 1 3400/16 = 212 Remainder 8 212/16 = 16 Remainder 4 13/16 = 0 Remainder 13 Remainders are expressed Hex numbers Answer: $D481

Hex to Decimal Write out the 1st 16 numbers Same as for binary to decimal E.g. F9E116 1x160 = 1 Ex161 =14x16 = 224 9x162 =9x256 = 2304 Fx163 =15x4096= 61440 = 63969

Another Binary to Hex Conversion Hex 7 C 3 F 7C3F16

Binary Coding Schemes To represent characters we use Binary Coding Schemes Two of the most popular are ASCII (American Standard Code for Information Interchange EBCDIC (Extended Binary Coded Decimal Interchange Code) Here are some ASCII codes CHARACTER ASCII A 01000001 – 41 in hex B 01000010 - 42 in hex C 01000011 - 43 in hex D 01000100 - 44 in hex BELL 00000111 – 7 in hex ESC 00011101 – 1B in hex

Binary Coded Decimal (BCD) Each digit is converted individually to it’s binary equivalent 2634 = 0010 0110 0011 0100 3825 = 0011 1000 0010 0101 Disadvantages are that arithmetic is more complicated and storage is inefficent. Used only in simple device where memory is not a problem e.g. Calculators, clocks, etc.

Negative Integers Most humans precede number with “-” (e.g., -2000) Accountants, however, use parentheses: (2000) Sign-magnitude Example: -1000 in hex? 100010 = 3 x 162 + e x 161 + 8 x 160 -3E816

2’s Compliment Used for negative binary numbers Procedure: E.g. Invert all the bits: 0 becomes 1 and 1 becomes 0 Add 1 E.g. To get –1 110 = 000000012 Invert all bits 11111110 Add 1 11111111 Ans: -110 = 111111112

2’s Compliment Using the TC notation, the Most significant indicates the sign. 1 means a negative number With 8 bits, can represent signed numbers in the range: +127 -1 0 -128 01111111 11111111 00000000 10000000 With N bits, can represent signed numbers in the range: (2N-1)-1 0 -(2N-1) TC is widely used because it is easy to manipulate. The sign bit is treated the same as the others

2s Compliment Clock Stepping clockwise increases the binary number Stepping anti-clockwise decreases the binary number Notice how when we add one to a negative number it’s values move closer to zero

Addition & Subtraction Addition of TC’s numbers same as normal binary addition Subtraction of TC’s numbers can use either A-B or A + TC(B) E.g. 01112 – 00112 = ??? Change second number to TC 0111 1101+ 0100 Answer: 01112 – 00112 = 01002

Decimal fractions to binary More info on p158 Clements. Question: Convert 0.6250 (decimal) to a binary fraction 0.3125 x 2 = 0.6250 yielding 0 0.625 x 2 = 1.2500 yielding 1 0.25 = 0.5000 yielding 0 0.5 x 2 = 1.0000 yielding 1 Ans:0.0101

Binary to Decimal fractions More info on p158 Clements.

Summary Decimal Binary Hexadecimal Arithmetic Converting between number bases Counting Coding schemes 2’s Compliment