How to reverse fixed point binary log algorithm for fractional power of 2?
问题 I found a fast binary logarithm algorithm for fixed points in an answer to this question: Fast fixed point pow, log, exp and sqrt, based on an algorithm by Clay S. Turner. Is it possible to "reverse" this to calculate fractional powers of two? e.g: // log2(3) = 1.5849609375 log2fix(196608, 16) == 103872 pow2fix(103872, 16) == 196608 Here's the code from Dan Moulding: #include <errno.h> #include <stddef.h> #include "log2fix.h" int32_t log2fix (uint32_t x, size_t precision) { int32_t b = 1U <<