I want to test if a number double x is an integer power of 10. I could perhaps use cmath\'s log10 and then test if x == (int) x?
double x
log10
x == (int) x
<
Your solution sounds good but I would replace the exact comparison with a tolerance one.
double exponent = log10(value); double rounded = floor(exponent + 0.5); if (fabs(exponent - rounded) < some_tolerance) { //Power of ten }