Download presentation

Presentation is loading. Please wait.

2
Binary Expression Numbers & Text CS 105

3
Binary Representation At the fundamental hardware level, a modern computer can only distinguish between two values, 0 and 1. We have to represent the information we want to store and manipulate in binary format.

4
Data Representation Number Text Images and graphics Audio Video

5
Positional Notation Base – Binary (2) 0, 1 – Octal (8) 0, 1, 2, 3, 4, 5, 6, 7 – Decimal (10) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 – Hexadecimal (16) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Positional Notation – 943 = 9 * 100 + 4 * 10 + 3 * 1 – 63578 = ?

6
Binary Expression (Binary to Decimal) Example1: To convert the binary number 100111 to decimal, we write: the binary string: 1 0 1 1 1 over the powers of 2: 16 8 4 2 1 16 + 4 + 2 + 1 = 23 Like bills, no matter how much money you want, I can always give the accurate amount by using 1, 2, 4, 8, 16, 32, … bills

7
Binary Expression (Decimal to Binary) Example2: To convert the decimal number 23 to binary, we do the following divisions, recording the quotients and the remainders 1. 23 divided by 2 has a quotient of 11 and a remainder of 1. 2. 11 divided by 2 has a quotient of 5 and a remainder of 1. 3. 5 divided by 2 has a quotient of 2 and a remainder of 1. 4. 2 divided by 2 has a quotient of 1 and a remainder of 0. 5. 1 divided by 2 has a quotient of 0 and a remainder of 1. 6. The sequence of remainders we obtained, when collected the reverse order is the binary representation of 23, namely 10111.

8
Binary Expression (Decimal to Binary) Combination of 1, 2, 4, 8, 16, 32, … bills – Decimal Number: 23 – 32 16 8 4 2 1 – 1. You have 23. Pick 16, and you have 7 left. – 2. You have 7. Pick 4 (8 is too large), and you have 3 left. – 3. You have 3. Pick 2, and you have 1 left. – 4. You have 1. Pick 1 – So, … 32 16 8 4 2 1 – We have 1 0 1 1 1 (binary expression for 23)

9
Binary representation. Remember, everything on a computer is stored as 0s and 1s. Thus, we must interpret these numbers as different forms of data. One bit (binary digit) can be either a 0 or a 1. –Therefore, it can only represent two possibilities: hot or cold, black or white, on or off, etc…

10
Numerical data Operation Multiply the binary number 101*1001. – 1 0 0 1 – x 1 0 1 – 1 0 0 1 – 0 0 0 0 – 1 0 0 1 – 1 0 1 1 0 1 Add the binary number 100110 + 111001. – 1 0 0 1 1 0 – + 1 1 1 0 0 1 – _________________ – 1 0 1 1 1 1 1

11
Data Representation Number Text Images and graphics Audio Video

12
Binary representation. cont. If we want to represent for things, we must use more bits. Two bits can be either 00, 01, 10, or 11. –Therefore, they can represent four possibilities: cold, cool, warm, or hot; black, white, and two gray levels; etc … This continues until we have enough bits to represent our data. –In general, n bits can represent 2 n things (ie, every time we add a bit, we double the number of things we can represent by two).

13
Some terminology. Up to this point we have been talking about data in either bits or bytes. – 1 byte = 8 bits While this is the correct way to talk about data, sometimes it is a bit inefficient. Therefore, we use prefixes to given an order of magnitude. – Much the same way we do with the metric system. The following is a list of the common terms. – Kilobyte (KB) = 10 3 = 1000 bytes – Megabyte (MB) = 10 6 = 1 million bytes – Gigabyte (GB) = 10 9 = 1 billion bytes – Terabyte (TB) = 10 12 = 1 trillion bytes – Petabyte (PB) 10 15 = 1 quadrillion bytes

14
Representing text. Now we know how numbers are represented by computers, but what about text, such as term papers, text messages, etc…? Well, we can use a technique that we’ve referenced a couple of times. That is, we can use numbers to represent elements of a set. –How could we represent the letters ‘a’ to ‘z’? –One possibility would be to use 0 as ‘a’ and 25 as ‘z’. –Is there a problem with this? –What if we wanted to represent the ‘the ABCs and 123s’? We’re going to need a way to represent all letters, numbers, symbols, and hidden characters. Remember newline? In fact there are many different systems used to do this, one of the most popular is the ascii system, which is used by notepad on windows. –ASCII stands for American Standard Code for Information Interchange.

15
ASCII Character Set

16
Ascii codes. cont. An ascii character is an 8 bit (1 byte) number interpreted to represent something. – 48 represents ‘0’ – 82 represents ‘R’ – 32 represents ‘ ’ (Space) – Etc … – How many characters can be represented by Ascii? A program can therefore interpret a chain of 8 bit numbers to represent a text document. – Notepad in Windows does just this. – In notepad, we can verify this by creating a new document. Typing a single letter in it then saving. If we now check the size of the document, you’ll see that it is 1 byte. Type another character and save … now it’s 2 bytes.

17
Representing text. cont. How about other characters (Latin, Russian, Thai, math symbols, Chinese, Japanese, Korean, …)? There are actually many other standards for representing text on computers aside from ASCII. One very common one is Unicode. – Unicode is a standard used to represent around 100,000 different characters covering most languages. – In fact, in Microsoft Word, try clicking Insert Symbol. You may notice in the right hand corner that the set of symbols is taken from Unicode. You will also be shown the Hexadecimal version of the code for that character. – Unicode uses a 16bit (2byte) or 32bit (4byte) code to represent characters depending on the version of Unicode. How many characters can Unicode represent?

Similar presentations

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google