Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional.

Similar presentations


Presentation on theme: "Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional."— Presentation transcript:

1 Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional parts

2 For example 1010 + 0011 _____ =1101 1 ^ Carry __|

3 Using these rules pairs of numbers plus a carry bit are added together starting for the right. When there is no carry from the previous addition operation the carry bit plays no part in the calculation it is as if the calculation was just bits A and B. When carry bit is set (a carry from the previous operation) the calculation is A+B+Carry. The carry bit after the final addition operation is ignored.

4 Binary subtraction Binary subtraction is performed by converting the second number into it’s two’s complement and adding. So there is not a need for a subtracting circuit. As an example: 14-6

5 Subtraction Example Number A=1400001110 Number B=600000110 Reverse bits in Number B11111001 +111111010 B 2’s Complement = C11111010 1400001110 2’s Complement of 611111010 add 800001000

6 How do we represent numbers with fractional parts? One way would to say that so many bits will represent whole numbers, and the remainder will represent fractional number such as 0.5, 0.25 or 0.125. An example of this could be the three most significant bits are used to represent whole numbers, the remaining bits represent 1/powers of 2 (e.g. 1/2, 1/4, 1/8, 1/6). The binary point (equivalent to a decimal point in decimal numbers) is between 1 and 1/2.

7 421½¼1/81/16 1011010

8 Therefore, from table 1 this number 101.101 represents the decimal number 4+1+0.5+0.125=5.625. So the number can be split into two parts the whole number part (in this case 101 (which is 5 in decimal)) and a fractional part 101.

9 Floating-point numbers Often we want to represent very small, very large numbers or numbers with fractional parts. For example,33550000 or 0.00000001451 the binary format we have already met is not capable, so we need another form. One way of doing this is scientific notation where these numbers are split into two parts a number with a decimal point within it (called the mantissa) and a power of 10 (called the exponent).

10 Fixed NotationScientific Notation MantissaExponent 335500000.3355x10 8 0.33558 0.000000014510.1451x10 -7 0.1451-7

11 So for example, the decimal number 5.625 could be represented as 101.101. If we use this mantissa and exponent idea, it could also be written as 0.101101x2 3 (Normalised) where the exponent shows the true position of the binary point (no longer a decimal point, as we are not using the decimal system) relative to the current position. Because the binary point can be altered depending on the magnitude of the exponent, it often refereed to as a floating-point representation.

12 IEEE standard (single precision) SignExponentMantissa Bit 31Bits 23-30Bits 0-22 -ve131 10 0.265625 10 11000001001000100000000000000000

13 Features with floating point representation Gives a wide range of numbers It is not precise Precision and Range can be improved using more bits (64 bits in Double precision) – Bit 63 for sign, – bits 52-62 for exponent – Bits 0 to 51 for mantissa

14 Summary There is no subtraction circuit, but there is addition circuitry. Subtract of binary integers can be converting a positive number into 2’s complement. Floating point number: ((sign)x(1+stored mantissa))x2 (stored exponent-127)

15 IEEE standard (single precision) SignExponentMantissa Bit 31Bits 23-30Bits 0-22 -ve131 10 0.265625 10 11000001001000100000000000000000

16 Sources for further reading Dick D(2003) pages 93-103. Chalk et al (2004) pages 20-23 Burrel (2004) Chapter 2 - pages 25 -34 Tannebaum (2005) pages 691-699


Download ppt "Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional."

Similar presentations


Ads by Google