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 theWideScalefunction to obtain the bit number of the highest order bit in the absolute value of awidenumber. Listing 8-3 shows how to use theWideScalefunction in a function that multiplies two numbers inlongformat. If the product is too big to fit in along, the function shifts the product so that it fits into alongand returns the bit shift. This operation can be termed pseudo-floating-point.Listing 8-7 Using the
WideScalefunction 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; }TheWideScalefunction is described on page 8-53.