CHDK includes a log2(x) function, but it computes it as:
log10(x)/log10(2)
As Phil pointed out to me when I was doing the shot meter code, double precision division is a lot slower than multiplication. So instead of using log2(x), it's faster to use:
log10(x)*(1/log10(2))
However, this requires storing another constant, and writing a longer expression, which takes more memory. Plus, it isn't obvious that you're doing a log2(x) equivalent.
Anyway, why don't we just change the definition of the log2(x) function like this:
lib/math/wrappers.c
//extern double _log2(double x);
double log2(double x) {
// return d2d( _log2( d2d(x) ) );
// return (log10(x)/((double)0.30102999566398119521373889472449));
return (log10(x)*((double)3.3219280948873623478703194294894));
}
I couldn't find any references to log2 in a search of all CHDK files, but I would use this version in my shot meter function. I'm also writing a new histogram that would use it, and I could modify the shooting.c functions to use it too.