LISTING 1 - BITLOG FUNCTION IMPLEMENTATION /* Bitlog function * Invented by Tom Lehman at Invivo Research, Inc., * ca. 1990 * * Gives an integer analog of the log function * For large x, * * B(x) = 8*(log(base 2)(x) - 1) */ short bitlog(unsigned long n) { short b; // shorten computation for small numbers if(n <= 8) return (short)(2 * n); // find the highest non-zero bit b=31; while((b > 2) && ((long)n > 0)) { --b; n <<= 1; } n &= 0x70000000; n >>= 28; cout << b << ' ' << n << endl; return (short)n + 8 * (b - 1); } listing 2 - integer exponential /* Bitexp function * returns an integer value equivalent to the exponential. For numbers > 16, bitexp(x) approx = 2^(x/8 + 1) */ unsigned long bitexp(unsigned short n) { unsigned short b = n/8; unsigned long retval; // make sure no overflow if(n > 247) return 0xf0000000; // shorten computation for small numbers if(n <= 16) return (unsigned long)(n / 2); retval = n & 7; retval |= 8; cout << dec << b << ' ' << hex << retval << endl; return (retval << (b - 2)); }