School of Business, Economics and Informatics Department of Management Binary Numbers 2 Eva Szatmari e.szatmari@bbk.ac.uk Learning Objectives • • • • • Recap BIN Fractions in BIN Two’s complement notation Excess notation Floating point notation Video Tutorials http://bbk.libguides.com/computerscience /mathstutorials http://www.bbk.ac.uk/mathstutorials/ https://www.youtube.com/playlist?list=PL2F y-5oxIlb6cG15wxnhRdAmdskil_3-7 Warning: floating point notation! Recap BIN • What are BIN nos? • How do we convert BIN to DEC? • How do we convert DEC to BIN? Fractions in BIN Example 1: 11.101 Example 2: 1010.1101 Fractions in BIN Example 1: 5¼ Example 2: 7¾ Example 3: 2 1 10 Fractions in BIN a) 101.0011 b) 1100.101 c) 7 7 16 d) 12 3 4 Fractions in BIN a) 101.0011 = 5 𝟑 𝟏𝟔 b) 1100.101 = 12 𝟓 𝟖 c) 7 7 16 = 111.0111 d) 12 3 4 = 1100.11 Two’s Complement Notation Negative numbers in BIN? Two’s complement Sign bit, distinguishing between negative and positive numbers What is 0 represented as in two’s complement notation? Two’s Complement Notation First fix the number of digits, e.g.: 4 bits Find the positive BIN equivalent Copy all digits from right to left till a 1 had been copied Complement (invert/flip) the rest of the digits Two’s Complement Notation 4 bits two’s complement Example 1: Example 2: -2 -4 6 bits two’s complement Example 3: Example 4: 100100 011001 Two’s Complement Notation 5 bits two’s complement: a) – 8 b) – 13 c) 10101 d) 11010 Two’s Complement Notation 5 bits two’s complement: a) – 8 = 11000 b) – 13 = 10011 c) 10101 = - 11 d) 11010 = - 5 Excess Notation Another way of representing negative numbers in BIN What is 0 represented as in excess notation? What positive numbers look like? What negative numbers look like? How many digits do you use? Excess Notation 4 bits excess: Example 1: -7 Example 2: -5 Example 3: 4 Example 4: 2 Excess Notation 4 bits excess: a) - 6 b) - 1 c) 5 d) 7 Excess Notation 4 bits excess: a) - 6 = 0001 b) - 1 = 0111 c) 5 = 1101 d) 7 = 1111 Floating Point Notation s e1e2e3 m1m2m3m4 What What What What does this sequence mean? is s? are e1e2e3? are m1m2m3m4? Floating Point Notation Normalization Example 1: 0.0011001 Exponent: Example 2: 101.10010 Exponent: Mantissa: Mantissa: Floating Point Notation Step1: identify the sign bit (0 for +, 1 for – numbers) Step 2: find the mantissa (move the radix point to 0.1… format, record the first 4 digits after the point) Step 3: find the exponent in 3 bits excess notation Step 4: record the number: s e1e2e3 m1m2m3m4 Floating Point Notation Example 1: −1 1 4 Example 2: −2 3 8 Example 3: 33 4 Example 4: 25 8 Floating Point Notation a) −1 7 b) −5 1 8 2 Floating Point Notation a) −1 7 b) −5 1 = 11011111 2 = 11111011 8 Floating Point Notation Example 1: 01011001 Example 2: 10101101 Example 3: 10101100 Example 4: 11011100 Floating Point Notation a) 10111011 b) 10011100 Floating Point Notation a) 10111011 = − 𝟏𝟏 𝟑𝟐 b) 10011100 = − 𝟑 𝟑𝟐 Any Questions? Contact Details Eva Szatmari 0207 631 6254 Or e.szatmari@bbk.ac.uk GOOD LUCK