On Sun, Aug 09, 2009 at 02:25:40PM +0200, Erik Faye-Lund wrote:
log10() appears to be C99, but can be emulated on earlier C-versions by doing
#define log10(x) (log(x) / log(10.0))
I don't think you'll like the results of this very much.
#include <math.h>
#include <stdio.h>
int main(void) {
double n=1;
int i, j;
for(i=0; i<10; i++, n*=10) {
j = (int)(log(n)/log(10));
if(i != j) printf("%d %d\n", i, (int)j);
}
return 0;
}
(on my system, 3 of the 10 tested cases give the wrong answer due to
rounding)
For a tour of some of the difficulties of implementing log10,
http://www.cs.berkeley.edu/~wkahan/LOG10HAF.TXT
Jeff