另一种方法,如果 x 是 16-bit 整数:
定义4 * 16 个系数, float Coeff[4][16] = { { 1, e^1, e^2, ..., e^15 }, { e^0x10, e^0x20, ..., e^0xF0}; { e^0x100, ..., e^0xF00 }; { e^0x1000, ..., e^0xF000 } };
计算:
float result = Coeff[0][x & 0x0F]; result *= Coeff[1][(x>>4) & 0x0F]; result *= Coeff[2][(x>>8) & 0x0F]; result *= Coeff[3][(x>>12) & 0x0F];
|