Important: The information in this document is obsolete and should not be used for new development.
Determining the Highest Order Bit of a wide Number
You can use theWideScale
function to obtain the bit number of the highest order bit in the absolute value of awide
number. Listing 8-3 shows how to use theWideScale
function in a function that multiplies two numbers inlong
format. If the product is too big to fit in along
, the function shifts the product so that it fits into along
and returns the bit shift. This operation can be termed pseudo-floating-point.Listing 8-7 Using the
WideScale
function to create a pseudo-floating-point function
long FloatMul(long a, long b, long *product) { wide temp; long shift = WideScale(WideMultiply(a, b, &temp)) - 30; if (shift > 0) WideShift(&temp, shift); else shift = 0; if (product) *product = temp.lo; return shift; }TheWideScale
function is described on page 8-53.