Texas Instruments TMS320C3x User Manual

Page 151

Advertising
background image

Fast Logarithms on a Floating-Point Device

5-46

are equivalent to the seven MSBs of the logarithm. If the exponent could hold
all the bits needed for full accuracy, then it would be possible to continue the op-
eration for all 24 bits of the mantissa. Since there are only eight bits in the expo-
nent and the MSBs are used for negative values, only seven iterations are pos-
sible before the exponent must be off-loaded and reinitialized to zero.

By concatenating EXP_new to the previous exponent, longer strings of bits can
be built for greater accuracy. The process is then repeated until the desired accu-
racy is achieved. Also remember that the original numbers exponent, which rep-
resents the whole number part of the result, becomes the eight MSBs of the final
result.

Another technique is to look at the three MSBs of the mantissa and apply a
roundup from the fourth bit. Those same MSBs can be used as a quick exten-
sion of the exponent (logarithm). To visualize this, consider the following tabu-
lated values and graph.

1.0

0.585

0.5

0.0

1.0

1.5

2.0

Mantissa

Fraction

Mant

log

2

(Mant)

1.000
1.250
1.500
1.7500
1.999

0.000
0.322
0.585
0.807
0.999

Figure 5–22. Tabulated Values for Mantissa

Note:

The fractional part is the same at the endpoints.

In the middle, only a slight bowing exists which can either be ignored or optionally
rounded for better accuracy. The maximum actually occurs at a mantissa value
of

1

ln(2.0)

or 1.442695. The value of log2(mant) at that point is 0.52876637, giving a maxi-
mum error of 0.086071.

Advertising