Abstraction – Number Systems and Data Representation

Slides:



Advertisements
Similar presentations
Representing Data, Pictures, Time, and Size in Computer
Advertisements

Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
CSC /703 CTI/DePaul1 CSC-255 Lecture 3 Text and Numerical Storage (Chapter 1 from Brookshear) Modified by Ufuk Verun from Jim Janossy © 2002, DePaul.
Binary and Hexadecimal Numbers
Binary Expression Numbers & Text CS 105 Binary Representation At the fundamental hardware level, a modern computer can only distinguish between two values,
28-Jun-15 Number Systems. 2 Bits and bytes A bit is a single two-valued quantity: yes or no, true or false, on or off, high or low, good or bad One bit.
Binary and Decimal Numbers
REPRESENTING INFORMATION: BINARY, HEX, ASCII C ORRESPONDING R EADING : UDC C HAPTER 2 CMSC 150: Lecture 2.
Number systems Converting numbers between binary, octal, decimal, hexadecimal (the easy way)
COMPUTER FUNDAMENTALS David Samuel Bhatti
Abstraction – Number Systems and Data Representation.
Georgia Institute of Technology Introduction to Programming Part 2 Barb Ericson Georgia Institute of Technology May 2006.
Binary Arithmetic & 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,
Data Representation and Storage Lecture 5. Representations A number value can be represented in many ways: 5 Five V IIIII Cinq Hold up my hand.
Number Systems Spring Semester 2013Programming and Data Structure1.
Computing Theory – F453 Number Systems. Data in a computer needs to be represented in a format the computer understands. This does not necessarily mean.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
Text and Graphics September 26, Unit 3.
The Hexadecimal Number System and Memory Addressing ISAT 121.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Data Representation, Number Systems and Base Conversions
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
Data Representation (in computer system). Data Representation How do computers represent data? b The computers are digital Recognize.
MECH1500 Chapter 3.
Georgia Institute of Technology Introduction to Programming Part 3 Barb Ericson Georgia Institute of Technology May 2006.
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
Number Systems. ASCII – American Standard Code for Information Interchange – Standard encoding scheme used to represent characters in binary format on.
Binary a. express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal;
Dr. Clincy Slide 1 CS Chapter 2 (Part 1 of 3) Dr. Clincy Professor of CS Ch 2 Appendix pages will not be on the exam – already covered this.
Lecture Coding Schemes. Representing Data English language uses 26 symbols to represent an idea Different sets of bit patterns have been designed to represent.
Some basic concepts underlying computer archi­tecture
Data Representation COE 308 Computer Architecture
Binary & Hex Review.
Binary Representation in Text
Binary Representation in Text
3 – Boolean Logic and Logic Gates 4 – Binary Numbers
Programming and Data Structure
Number Systems and Codes
Data Representation ICS 233
Binary 1 Basic conversions.
Data Representation.
Introduction to Programming Part 2
Number Representation
3.1 Denary, Binary and Hexadecimal Number Systems
What is a byte? What is it? How would you use it?
Lesson Objectives Aims
CSCI 198: Lecture 4: Data Representation
Integer Real Numbers Character Boolean Memory Address CPU Data Types
Dr. Clincy Professor of CS
Chapter 3 Data Storage.
CSCI 161: Lecture 4: Data Representation
What is Binary? Binary is a two-digit (Base-2) numerical system, which computers use to process and store data. The reason computers use the binary system.
Introduction to Programming Part 3
Coding Schemes and Number Systems
Data Representation COE 301 Computer Organization
Dr. Clincy Professor of CS
Ch2: Data Representation
Introduction to Programming Part 2
How Computers Store Data
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Data Representation ICS 233
Introduction to Programming Part 3
Binary System.
23/04/2019 Data Representation Conversion.
Binary & Hex Review.
Number systems Converting numbers between binary, octal, decimal, hexadecimal (the easy way)
Data Representation COE 308 Computer Architecture
Presentation transcript:

Abstraction – Number Systems and Data Representation

Memory Computer memory is used to store data The smallest unit of memory is a bit (Binary digIT) A bit can be off (no voltage) or on (has voltage) which we interpret to be 0 or 1 Memory is organized into 8 bit contiguous groups called bytes. A megabyte is 1,048,576 bytes (over 1 million bytes). A gigabyte is over 1 billion bytes. See http://computer.howstuffworks.com/bytes1.htm.

How does Memory Represent Values? The different patterns of the on and off bits in a byte determine the value stored Numbers are stored using binary numbers 101 is 1 * 20 + 0 * 21 + 1 * 22 = 5 Characters are internally represented as numbers Different numbers represent different characters There are several systems for assigning numbers to characters: ASCII, EBCDIC, and Unicode See http://www.webopedia.com/TERM/A/ASCII.html for information about ASCII. Most computers store text in ASCII. ASCII uses 7 or 8 bits to store characters. See http://www.webopedia.com/TERM/E/EBCDIC.html for information on EBCDIC. EBCDIC is used on IBM computers. See http://www.webopedia.com/TERM/U/Unicode.html for information on Unicode which is a 16 bit format that can represent Greek, Chinese and Japanese as well as English characters.

Encodings Make Computers Powerful Voltages are interpreted as numbers Numbers can be interpreted as characters Characters can be interpreted to be part of a link to www.google.com A byte of memory might contain the values “off on off off off off off on” which we assign the binary numbers of “0100 0001” which is the encoding for the letter “a” in ASCII which could be part of a link to Sun’s Java web site. Each layer of encoding is handled by software. a 0100 0001 off on off off off off off on

Notepad Exercise Open notepad and type a sentence in it Save the file Check the size in bytes by leaving the cursor over the file name Or right click and check properties Now count the number of letters and spaces Notepad is using 8 bits per character or 1 byte per character to store letters, spaces, and punctuation. Look at the sizes of files on your computer. How many bytes do they have?

Binary Numbers A bit is a binary digit with a value of 0 or 1 A group of 8 bits is a byte Computer memory is allocated in bytes Numbers are stored using the binary number system With digits of 0 or 1 and powers of 2 Other number systems Decimal- digits of 0 to 9 and powers of 10 Octal - digits of 0 to 7 and powers of 8 Hexadecimal – digits of 0 to 9 and A, B, C, D, E, F and powers of 16.

Converting from Binary to Decimal Multiply the digit value times the place value and add up the results to convert from binary to decimal The place values start with 20 on the right (which is 1) and increase to the left

Converting from Decimal to Binary Subtraction Method Keep subtracting out largest power of two until nothing remains Slide is from Mary Moynihan

Converting from Decimal to Binary Division Method Read result from top to bottom. Slide is from Mary Moynihan

Binary Addition To add two decimal numbers you add the digits and if the total is greater than ten you carry the one into the next column To add two binary numbers 0 + 0 = 0 0 + 1 and 1 + 0 = 1 1 + 1 = 0 with a carry of 1 into the next column to the left 00 10 111 01 01 001 ---- --- ------ 01 11 1000 00111001010 01010101101 ------------------- 10001110111

2’s Compliment Notation Computers actually only know how to add So, how do they handle subtraction? Computers subtract by adding a negative number How do you represent a negative number in memory? Positive numbers in 2’s compliment are just the same as a binary number For negative numbers reverse 0s and 1s and then add 1 See http://gs.fanshawec.ca/tlc/math270/1_7_Two's_Comp_Arith.htm and http://courses.cs.vt.edu/~csonline/NumberSystems/Lessons/SubtractionWithTwosComplement/Lesson.html for information on 2’s compliment

2’s Compliment Example To subtract 3 from 7 First represent both as a binary number 7 is 0000 0111 3 is 0000 0011 Reverse the 0s and 1s and then add 1 to get -3 0000 0011 reversed is 1111 1100 add 1 0000 0001 The result is 1111 1101 In 2’s Compliment positive number are represented as regular binary numbers. Negative numbers will always have the leftmost bit as 1. Positive numbers will always have the leftmost bit as 0.

Add the Negative Number To subtract 3 from 7 Add -3 to 7 7 is 0000 0111 -3 is 1111 1101 The result is 1 0000 0100 Throw away the leftmost 1 The answer is 0000 0100 which is 4

Fun with Math. Complete the following problems in BINARY: 1. 13+9= 2. 7-2= 3. 74+36= 4. 5-4= 5. 01001111 + 7= 6. 00010110 – 4=

Patterns Exercise How many different patterns of on and off bits are there in 3 bits? How many in 4 bits? How many in 8 bits? 000 is one pattern 001 is another pattern 010 is another pattern

Does the number of patterns matter? Some garage door openers in the 70s used 8 bits to set the code to use to open the door Giving 256 different patterns Which is enough that you won’t open your neighbors door But small enough that someone could try each one The picture shows a garage door opener from the 90s with 12 bits.

Remote Entry Systems With 8 bits for a code you have a 1/256 chance of a random code working You don’t want someone opening your car in a place with lots of cars (like a mall) There are also radio scanners that can capture your code So you want the code to change each time Modern remote entry systems use a 40 bit rolling code See http://auto.howstuffworks.com/remote-entry2.htm for more information on remote entry systems.

Quick Review…

Quick Review…

Hexadecimal (Hex)

Hexadecimal Hexadecimal is really no different from binary or decimal. The idea behind its creation was to find ways to store more information in a smaller space. With a base multiplier of 16, you get double the memory, for almost half the space. http://www.teach-ict.com/gcse_computing/ocr/214_representing_data/number/miniweb/pg8.htm