Pages: <Previous  25    26    27    28    29    30    31    32    33    34    35  Next >

7 Binary arithmetic

7.6 Arithmetic with binary fractions

My final point in the preceding section brings home the fact that integer arithmetic is not really suitable when divisions are to be performed. It is also not suitable where some or all of the values involved in the arithmetic are not – or are not necessarily – integers, and this is often the case. In such cases, arithmetic has to be performed on non-integers.

The most common representation for non-integers is the floating-point representation that I mentioned briefly in Box 3. You may recall that numbers are represented in the form (mantissa × 2exponent), where the mantissa is a fixed-point fraction and the exponent a signed integer. Arithmetic with floating-point numbers may therefore involve calculations such as

(0.111 0001 × 210) + (0.000 1000 = 25)

(1.101 1000 × 2−5) − (1.000 1000 × 2−6)

(0.101 1100 × 215) / (0.111 0101 ×2−12)

Such arithmetic is by no means straightforward, and I have no intention of trying to show you how it is carried out. Most processors destined for PCs, workstations and other powerful computers include a ‘floating-point unit’ whose sole task is to carry out operations on floating-point numbers. If a processor without a floating-point unit is to be used to perform floating-point arithmetic then the software will have to take care of the complicated manipulations involved.

Pages: <Previous  25    26    27    28    29    30    31    32    33    34    35  Next >