Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional parts
For example _____ = ^ Carry __|
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.
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
Subtraction Example Number A= Number B= Reverse bits in Number B B 2’s Complement = C ’s Complement of add
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 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.
421½¼1/81/
Therefore, from table 1 this number represents the decimal number = 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.
Floating-point numbers Often we want to represent very small, very large numbers or numbers with fractional parts. For example, or 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).
Fixed NotationScientific Notation MantissaExponent x x
So for example, the decimal number could be represented as If we use this mantissa and exponent idea, it could also be written as x2 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.
IEEE standard (single precision) SignExponentMantissa Bit 31Bits 23-30Bits ve
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 for exponent – Bits 0 to 51 for mantissa
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)
IEEE standard (single precision) SignExponentMantissa Bit 31Bits 23-30Bits ve
Sources for further reading Dick D(2003) pages Chalk et al (2004) pages Burrel (2004) Chapter 2 - pages Tannebaum (2005) pages