Presentation is loading. Please wait.

Presentation is loading. Please wait.

Binary 1 Basic conversions.

Similar presentations


Presentation on theme: "Binary 1 Basic conversions."— Presentation transcript:

1 Binary 1 Basic conversions

2 Base 10 uses the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 represents digits as multiples of 1, 10, 100, 1000, etc… 100 10 1 594 5 9 4 = 594 42 2 = 42 420 = 420 402 = 402

3 Base 2 (Binary) Uses the digits 0, 1
Each column represents a “power of two” 0s and 1s are known as “bits”, short for “binary digits” 128 64 32 16 8 4 2 1 Decimal = 17 = 82 = 132 = 201

4 Binary to decimal… practise!
128 64 32 16 8 4 2 1 Decimal

5 Solutions Binary 128 64 32 16 8 4 2 1 Decimal = 44 = 88 = 163 = 195 = 248 = 113 = 85 = 102 = 255

6 What about going the other way?
For example, how might we determine the binary equivalent of each of the following decimals? 4 16 17 15 12 39

7 Decimal to binary – One method
Find the highest power of two that is less than the number you want to convert, then subtract, and repeat. Convert 39 into binary Does 128 fit into 39? No Does 64 fit into 39? No Does 32 fit into 39? Yes What’s left over? = 7 Does 16 fit into 7? No Does 8 fit into 7? No Does 4 fit into 7? Yes What’s left over? 7-4 = 3 Does 2 fit into 3? Yes What’s left over? 3-2 = 1 Does 1 fit into 1? Yes What’s left over? 1-1=0 Decimal 39 => binary

8 Decimal to binary… practise!
128 64 32 16 8 4 2 1 Binary 5 19 27 35 49 87 232 240

9 Solutions Decimal 128 64 32 16 8 4 2 1 Binary 5 19 27 35 49 87 232 240

10 Binary fractions We can convert fractions in much the same way as whole numbers Binary 2 1 . ½ .5 ¼ .25 1/8 .125 1/ 1/ 1/ Decimal 1.1 = 1.5 10.011 = 2.375 0.0111 = =

11 Binary fractions What if the fractions we want to convert from decimal to binary aren’t “easy”? 0.4 0.85 Division by 2 We repeatedly divide a number by two to get the final solution

12 Convert decimal 0.4 to binary
Multiply by 2 Put the whole number part in one column Put the remainder in the next column Copy the remainder to the start of the next row Repeat There is no rule how many times you should do this, but five “binary places” will be fine for us The “whole number” column, read from top to bottom, is the binary fraction Decimal Whole number Remainder 0.4 x 2 = 0.8 1 0.6 0.2 Therefore 0.4 => … 0.410 = (to 5 binary places)

13 Decimal fractions to binary… practise!
Convert 0.3 to binary Convert 0.24 to binary Decimal Whole number Remainder 0.3 x 2 = Decimal Whole number Remainder 0.24 x 2 =

14 Data representation How could we send a secret message to someone else using only binary digits (bits)? How many bits would be needed per letter? What if we wanted to use upper and lower case letters? What about all the other symbols on the keyboard? (and don’t forget the characters that aren’t displayed, such spaces, tabs, line breaks, etc.)

15 ASCII ASCII Decimal Binary
? 63 @ 64 A 65 B 66 C 67 D 68 E 69 F 70 G 71 H 72 I 73 J 74 K 75 “ASCII” (American Standard Code for Information Interchange) encodes 128 characters into 7-bit binary integers. Eight-bit machines typically set the eighth (left-most) bit to 0. It was originally based on the English alphabet, and includes both printable and non- printable characters. It was the most common character-encoding scheme on the web until 2007.

16 Unicode What if we want to represent more than just English characters? Unicode is a system for providing support for many different languages. Unicode can be implemented in different ways, but the most common are UTF-8 (8 bits) or UTF-16 (16 bits). Unicode is a superset of ASCII, the numbers have the same meaning in ASCII as they do in Unicode. The latest definition of Unicode includes almost 100,000 characters.

17 ASCII characters Convert the following using the ASCII table:
Decimal # 100 F 84 p 32

18 Solutions Character Decimal # 35 d 100 F 70 T 84 p 112 (space) 32


Download ppt "Binary 1 Basic conversions."

Similar presentations


Ads by Google