Number Representation

Slides:



Advertisements
Similar presentations
Base Conversion COP Practice Problem  Print a String in reverse order:  For example, if we want to print “HELLO” backwards,  we first print:
Advertisements

DATA REPRESENTATION CONVERSION.
EMB1006 The Binary System There is no 2 Jonathan-Lee Jones.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Review Binary Basic Conversion Binary Decimal
CISCO NETWORKING ACADEMY Chabot College ELEC 74A Hexadecimal Introduction.
© 2010 Kettering University, All rights reserved..
 Binary Binary  Binary Number System Binary Number System  Binary to Decimal Binary to Decimal  Decimal to Binary Decimal to Binary  Octal and Hexadecimal.
Number systems Converting numbers between binary, octal, decimal, hexadecimal (the easy way)
Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.
Data Storage Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information Technology Islamic.
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
COMPSCI 210 Semester Tutorial 1
Positional Notation 642 in base 10 positional notation is:
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.
Chapter 2 Bits, Data Types, and Operations. 2-2 Hexadecimal Notation It is often convenient to write binary (base-2) numbers as hexadecimal (base-16)
Hexadecimal Data Representation. Objectives  Know how the Hexadecimal counting system works  Be able to convert between denary, binary & hexadecimal.
Data Representation Hexadecimal  Although computers work in binary it is sometimes inconvenient for humans to read everything in Binary. For example in.
DECIMALBINARY a) b) c) d) e) f) Revision Exercise DECIMALBINARY a) b) c)
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
CSC 110 – Intro to Computing Lecture 3: Converting between bases & Arithmetic in other bases.
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.
Two’s Complement The language of machines, part II.
Conversions 1)Binary to Denary Method 1 Work out the position values of the binary bits and add those values together So above would be
Binary Arithmetic James A. Rome Tennessee Governor's Academy August 2010.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Dr. ClincyLecture 2 Slide 1 CS Chapter 2 (1 of 5) Dr. Clincy Professor of CS Note: Do not study chapter 2’s appendix (the topics will be covered.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Negative Number Sign-Magnitude: left-most bit as the sign bit –16 bits –Example: 4-bit numbers is given by is given by ’s complement:
Department of Computer Science Georgia State University
Binary & Hex Review.
Lecturer: Santokh Singh
Unit 2.6 Data Representation Lesson 1 ‒ Numbers
Compsci 210 Tutorial Two CompSci Semester Two 2016.
Unit 18: Computational Thinking
2's Complement Arithmetic
By: Jonathan O. Cabriana
Data Representation Integers
Logistics Always read the Calendar at
ITE102 – Computer Programming (C++)
CSE 102 Introduction to Computer Engineering
Number Systems Lab session 1 Xuan Guo.
2.0 COMPUTER SYSTEM 2.2 Number System and Representation
Lesson objectives Understand how computers represent and manipulate numbers [unsigned integers, signed integers (sign and magnitude, Two’s complement)
Number System conversions
Number Systems and Bitwise Operation
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Data Storage Introduction to computer, 2nd semester, 2010/2011
Number Representation
Number Systems Base 2, 10, 16.
Binary, Octal and Hex Numbers Copyright Thaddeus Konar
Dr. Clincy Professor of CS
Unit 2.6 Data Representation Lesson 1 ‒ Numbers
Hexadecimal Conversions
2’s Complement Arithmetic
Numbering Systems and Arithmetic operations on Hex, binary, and octal
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Unit 18: Computational Thinking
COMS 161 Introduction to Computing
COMS 161 Introduction to Computing
Number Systems.
CPS120: Introduction to Computer Science
Number Representation & Operators
COMS 161 Introduction to Computing
Binary & Hex Review.
Chapter3 Fixed Point Representation
Number systems Converting numbers between binary, octal, decimal, hexadecimal (the easy way)
Binary Values and Number Systems
Presentation transcript:

Number Representation Tutorial One Number Representation CompSci 210 - Semester One 2017

Introductions Who am I: Callan Christophersen Contact: cchr158@aucklanduni.ac.nz Office hours: Monday 10am, Friday 11am. Where to find me: outside the games lab on the 4th floor. Take south side lifts to 4th floor, then turn left. CompSci 210 - Semester One 2017

Value of a Decimal Number Examine the decimal number “210” We reflexively understand the value to be, 200+10+0=210 This is because, 2⋅100+1⋅10+0⋅1=210 We use 100, 10, and 1 because we are told the number is a decimal number and decimal numbers use base 10 100= 10 2 ,10= 10 1 , 1= 10 0 Remember: “210” does not have a value until we calculate it CompSci 210 - Semester One 2017

Value of a Binary Number Now examine the binary number “101” Since we probably don’t reflexively understand the value, we must work backwards We use 4, 2, and 1 because we are told the number is a binary number and binary numbers use base 2 2 2 =4, 2 1 ,=2, 2 0 =1 In the formula, this becomes, 1⋅4+0⋅2+1⋅1=5 Note: We usually perform our calculations using decimal numbers CompSci 210 - Semester One 2017

Value of a 2’s Complement Number Now examine the 2’s complement number “10001101” 2’s complement numbers include a sign bit, and negative numbers are represented by their complementary bits This number is negative, because the leftmost bit is 1 The complement of the other bits is, 0001101→1110010+1=1110011 “1110011” represents a regular binary number, so, 2 6 =64, 2 5 =32,…, 2 0 =1 1⋅64+1⋅32+1⋅16+0⋅8+0⋅4+1⋅2+1⋅1=115 Remember: The number is negative, so the final value is, −115 CompSci 210 - Semester One 2017

Decimal to Binary Conversion CompSci 210 - Semester One 2017

Convert 102 to binary Decimal Value: 102 102 / 2 = 51 R 0 51 / 2 = 25 R 1 25 / 2 = 12 R 1 12 / 2 = 6 R 0 6 / 2 = 3 R 0 3 / 2 = 1 R 1 1 / 2 = 0 R 1 0 / 2 = 0 R 0 CompSci 210 - Semester One 2017

Convert 102 to binary Decimal Value: 102 102 / 2 = 51 R 0 51 / 2 = 25 R 1 25 / 2 = 12 R 1 12 / 2 = 6 R 0 6 / 2 = 3 R 0 3 / 2 = 1 R 1 1 / 2 = 0 R 1 0 / 2 = 0 R 0 0 1 1 0 0 1 1 0 Answer: 01100110 CompSci 210 - Semester One 2017

Conversion Between Hex and Binary Converting between hexadecimal and binary is easy! Recall that hexadecimal uses the normal digits 0-9, plus the letters A-F to represent the values 10-15. 0 1 2 3 4 5 6 7 8 9 A B C D E F CompSci 210 - Semester One 2017

Conversion Between Hex and Binary Every hexadecimal digit can be converted into a 4 digit binary number. Examples: 0 16 = (0000) 2 3 16 = (0011) 2 8 16 = (1000) 2 B 16 = (1011) 2 F 16 = (1111) 2 CompSci 210 - Semester One 2017

Convert hex to binary 0101110100010100 Split the number into groups of four, starting on the right 0101 1101 0001 0100 Calculate the hexadecimal value for each group 5 D 1 4 Write the solution with the correct sign 0x5D14 (‘0x’ is often used to indicate a hex value) CompSci 210 - Semester One 2017

Ands & Ors Oring 2 bits E.g. 1 OR 0 = 1 A B A OR B 0 0 0 0 1 1 1 0 1 0 0 0 0 1 1 1 0 1 1 1 1 Anding 2 bits E.g. 1 and 0 = 0 A B A&B 0 0 0 0 1 0 1 0 0 1 1 1 Anding binary strings This is done bitwise 11001010111 and 00100101011 00000000011 ORing binary strings This is also done bitwise 11001010111 and 00100101011 11101111111 CompSci 210 - Semester One 2017

Binary multiplication – the silly way Lets use an example: 10 x 20 = 200 or 1010 x 10100 = 11001000 One way to calculate this is 10+10+10+10+…+10 = 200 Or you could use a better way… CompSci 210 - Semester One 2017

Binary multiplication – a better way Using the same example: 10 x 20 = 200 or 1010 x 10100 = 11001000 1010 10100 101000 1010000 10100000 101000000 000000000 000101000 011001000 CompSci 210 - Semester One 2017