Agenda Data Representation Purpose Numbering Systems Binary, Octal, Hexadecimal (Hex) Numbering System Conversions Binary to Octal, Octal to Binary Binary.

Slides:



Advertisements
Similar presentations
NUMBER SYSTEM. How to convert hexadecimal numbers to decimal numbers? 230 Working from right to left, MULTIPLY each position with 8 raised to the power.
Advertisements

Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
The Binary Numbering Systems
A-Level Computing#BristolMet Session Objectives#8 express numbers in binary, octal and hexadecimal explain the use of code to represent a character set.
Data Representation Computer Organization &
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Data Representation COE 205
Representations Example: Numbers –145 –CVL – –91 –
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
Data Representation in Computers
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
Professor Jennifer Rexford COS 217
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
The Binary Number System
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.
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Computer Science 101 Number Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.
ENEL 111 Digital Electronics Richard Nelson G.1.29
Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.
Digital Logic Chapter 2 Number Conversions Digital Systems by Tocci.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Chapter 16 Binary and Hexadecimal Numbers. §16.2 thru 16.3 – Addition and Subtraction of Binary Numbers Binary = Base 2 Addition and subtraction are similar.
Real Numbers and the Decimal Number System
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Simple Data Type Representation and conversion of numbers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
Numbering systems.
Numeral Systems Subjects: Numeral System Positional systems Decimal
Computers Organization & Assembly Language
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
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.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
Computer Math. The Decimal System How do we represent “One Hundred and Twenty Five”? How do we represent “One Hundred and Twenty Five”? Simple: 125 !!!
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.
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.
The Teacher CP4 Binary and all that… CP4 Revision.
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.
The Hexadecimal Number System and Memory Addressing ISAT 121.
CPS120: Introduction to Computer Science Computer Math: Converting to Decimal.
© 2010 Cisco Systems, Inc. All rights reserved. 1 Network Math.
1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic.
The Teacher CP4 Binary and all that… CP4 Revision.
1 COMS 161 Introduction to Computing Title: The Digital Domain Date: September 6, 2004 Lecture Number: 6.
Chapter 2 Number Systems: Decimal, Binary, and Hex.
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
Data Representation, Number Systems and Base Conversions
AEEE2031 Data Representation and Numbering Systems.
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=
Number Systems by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
Lecture 2: 8/29/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Lec 3: Data Representation
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CSE 102 Introduction to Computer Engineering
Chapter 3 Data Representation
Presentation transcript:

Agenda Data Representation Purpose Numbering Systems Binary, Octal, Hexadecimal (Hex) Numbering System Conversions Binary to Octal, Octal to Binary Binary to Hex, Hex to Binary

Data Representation  Manipulating binary data on the computer:  C Programming: Convert lowercase to uppercase. Network communication. Unix: Set access permissions for directories, files  Webpage Programming: Set the colour of webpage background, text and links Before you can program at the “machine level” you need to understand how computers store data such as numbers and characters.

Binary Code Each digit in the binary code (i.e “0” or “1”) is called a bit. A certain number of bits are used to represent a character or a digit (part of a large number) called a byte. How many of these binary digits (bits) should be put together to form a code (byte) to represent all the characters / numbers on a computer system?

Binary Code A mathematical formula is used to determine the total number of character / number possibilities for binary code: 2^n Earlier computers used binary codes that consisted of either 7 or 8 bits. Newer computers use binary codes consisting of multiples of 8 (e.g. 8, 16, 32, 64 bit computers). The “2” represents the binary code (i.e. “0” and “1” in the code). The “n” represents the total number of digits in the binary code. Example: 2^8 = 256 Therefore, an eight-digit binary code would allow a total of 256 characters, or positive integers from 0 to 255, or integers from –128 to 127. Remember that zero takes up one of those numbers as well!

Numbering Systems Humans are most comfortable with the decimal numbering system (numbers with digits 0 - 9). Early in computer development, humans were forced to communicate with (and program) computers in “binary” which was time-consuming. To compromise, humans used other numbering systems (such as octal & hexadecimal) to provide a condensed (“short-hand”) method when working with computers. Binary, octal and hexadecimal numbers are sometimes still used in programming commands as well as Unix commands.

Numbering Systems Decimal (Base 10) numbering system for humans Binary (Base 2) numbering system for computers Octal(Base 8)/ Hexadecimal(Base16) Short-hand (short-cut) method of representing binary numbers

Decimal Numbers (Base 10)  Look at number 3,572 as sums of powers of 10: 3x10^3 = 3x1000 = x10^2 = 5x100 = x10^1 = 7x10 = x10^0 = 2x1 = 2 = 3,572

Binary Numbering System You can use the same method to convert a binary number to a decimal number: Multiply digits with appropriate power of 2 (i.e. 2^0, 2^1, 2^2, 2^3, etc…) Add results together to determine decimal number.

Binary Numbers (Base 2)  Convert binary number to a decimal number: 1x2^7 = 1x128 = x2^6 = 0x64 = 0 + 1x2^5 = 1x32 = x2^4 = 0x16 = 0 + 0x2^3 = 0x8 = 0 + 1x2^2 = 1x4 = 4 + 0x2^1 = 0x2 = 0 + 0x2^0 = 0x1 = (Decimal number) Therefore the binary code represents the decimal number 164.

Octal Numbers (Base 8)  Convert the octal number 264 to a decimal number: 2x8^2 = 2x64 = x8^1 = 6x8 = x8^0 = 4x1 = 4 = 180 (Decimal number) Therefore the octal number 264 represents the decimal number 180.

Hexadecimal Numbers (Base 16)  Convert the Hexadecimal number A1C to a decimal number: Ax16^2 = 10x16^2 = 10x256 = x16^1 = 1x16^1 = 1x16 = 16 + Cx16^0 = 12x16^0 = 12x1 = 12 = 2588 (Decimal number) Therefore the hexadecimal number A1C represents the decimal number Note - In Hex: A = 10 B = 11 C = 12 D = 13 E = 14 F = 15

Numbering System Shortcuts  There is a relation between binary digits and other number systems like octal and hexadecimal (hex):  1 Octal digit = 3 binary digits  1 Hex digit = 4 binary digits  Some Unix operations require working at the binary level. Since working at the binary level is tedious, certain Unix commands allow for the use of octal numbers to efficiently represent binary code.

Binary to Octal Conversion  Convert the binary number to an octal number: = x 2^2 2^1 2^0 2^2 2^1 2^0 2^2 2^1 2^0 i.e. (4) (2) (1) (4) (2) (1) (4) (2) (1) 1x4+ 1x2+ 1x1 1X4+ 1x2+ 0x1 0X4+ 0x2+ 0x1 = Therefore, the binary number represents 760 as an octal number. This code can be used to represent directory and file permissions (you will learn how to set permissions next week). Remember: 1 octal number is equal to 3 binary numbers. Group binary numbers into groups of 3’s starting from the right and multiply each digit by the appropriate power of 2, then add.

Octal to Binary Conversion  Similar to previous calculation, but in reverse:  Convert octal number 760 to binary.   (4)(2)(1) (4)(2)(1) (4)(2)(1)  = “Spread-out” octal number to make room for binary number result. Determine digits (0’s or 1’s) that are required when multiplied by appropriate power of 2 to add up to octal digit.

Binary to Hex Conversion  Convert the binary number to a hexadecimal number: = (8) (4) (2) (1) (8) (4) (2) (1) (8) (4) (2) (1) F 0 Therefore, the binary number represents 1F0 as a hexadecimal number. Note: 1 hexadecimal number is equal to 4 binary numbers. Group binary numbers into groups of 4’s starting from the right. Add leading zeros if last group of digits is less than 4. To obtain result, multiply digit by appropriate power of 2, then add.

Hex to Binary Conversion  Similar to previous calculation, but in reverse:  Convert hexadecimal number 1F0 to binary.  1 F 0   (8)(4)(2)(1) (8)(4)(2)(1) (8)(4)(2)(1)  = = “Spread-out” hex number to make room for binary number result. Determine digits (0’s or 1’s) that are required when multiplied by appropriate power of 2 to add up to hexadecimal digit.

Hexadecimal Numbers Example When creating a webpage, you can set the background colour by using a formatting tag with a hexadecimal number. Example: Each 2 digit pairs indicate a colour intensity. Example of bgcolor attribute: 66 – Red colour setting ff - Blue colour setting 99 - Green colour setting The combination of red, blue and green colour settings will create any colour desired. Check the “webpage colour selector” link contained in UNX122 course notes!

Representing Signed Numbers in Binary  An interesting technique is used to represent signed (positive and negative) numbers: The first bit is used to represent a negative number. The remaining bits are positive. The negative (or positive number if the first bit is 0) is determined by adding sums of the power of 2.  Eg = -(1x2^7)+1x2^6+1x2^5+0x2^4+0X2^3+1x2^2+0x2^1+1x2^0  = -27 (if recognized as a signed integer)  Eg = -(0x2^7)+1x2^6+1x2^5+0x2^4+0X2^3+1x2^2+0x2^1+1x2^0  = +101 (if recognized as a signed integer) The computer uses special mathematical tricks such as “bit-shifting” and “two’s complement” to perform common mathematical operations other than simply add numbers.