Presentation is loading. Please wait.

Presentation is loading. Please wait.

Number Representation

Similar presentations


Presentation on theme: "Number Representation"— Presentation transcript:

1 Number Representation
Tutorial One Number Representation CompSci Semester One 2017

2 Introductions Who am I: Callan Christophersen
Contact: 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 Semester One 2017

3 Value of a Decimal Number
Examine the decimal number “210” We reflexively understand the value to be, =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 2 ,10= 10 1 , 1= 10 0 Remember: “210” does not have a value until we calculate it CompSci Semester One 2017

4 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 =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 Semester One 2017

5 Value of a 2’s Complement Number
Now examine the 2’s complement number “ ” 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, → = “ ” 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 Semester One 2017

6 Decimal to Binary Conversion
CompSci Semester One 2017

7 Convert 102 to binary Decimal Value: / 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 Semester One 2017

8 Convert 102 to binary Decimal Value: / 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 Answer: CompSci Semester One 2017

9 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 A B C D E F CompSci Semester One 2017

10 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 Semester One 2017

11 Convert hex to binary Split the number into groups of four, starting on the right 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 Semester One 2017

12 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 and ORing binary strings This is also done bitwise and CompSci Semester One 2017

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

14 Binary multiplication – a better way
Using the same example: 10 x 20 = 200 or 1010 x = 1010 10100 101000 CompSci Semester One 2017


Download ppt "Number Representation"

Similar presentations


Ads by Google