Presentation is loading. Please wait.

Presentation is loading. Please wait.

Abstraction – Number Systems and Data Representation

Similar presentations


Presentation on theme: "Abstraction – Number Systems and Data Representation"— Presentation transcript:

1 Abstraction – Number Systems and Data Representation

2 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

3 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 * * * 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 for information about ASCII. Most computers store text in ASCII. ASCII uses 7 or 8 bits to store characters. See for information on EBCDIC. EBCDIC is used on IBM computers. See for information on Unicode which is a 16 bit format that can represent Greek, Chinese and Japanese as well as English characters.

4 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 A byte of memory might contain the values “off on off off off off off on” which we assign the binary numbers of “ ” 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 off on off off off off off on

5 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?

6 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.

7 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

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

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

10 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 and = 1 1 + 1 = 0 with a carry of 1 into the next column to the left

11 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 and for information on 2’s compliment

12 2’s Compliment Example To subtract 3 from 7
First represent both as a binary number 7 is 3 is Reverse the 0s and 1s and then add 1 to get -3 reversed is add The result is 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.

13 Add the Negative Number
To subtract 3 from 7 Add -3 to 7 7 is -3 is The result is Throw away the leftmost 1 The answer is which is 4

14 Fun with Math. Complete the following problems in BINARY: 1. 13+9=
2. 7-2= = 4. 5-4= = – 4=

15 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

16 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.

17 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 for more information on remote entry systems.

18 Quick Review…

19 Quick Review…

20 Hexadecimal (Hex)

21 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.


Download ppt "Abstraction – Number Systems and Data Representation"

Similar presentations


Ads by Google