Quote:
Originally posted by Dark_Helmet
Interesting point. I'm guessing that may be a copy-paste error in the man page.
[snip]
|
Yes, I, too, think it's an error in the manual. I get
Code:
$ c99 -lm -o test test.c
$ ./test 1 2 3 4 5 6 7 8
Log base 2 of 1.000000 is 0.000000
Log base 2 of 2.000000 is 1.000000
Log base 2 of 3.000000 is 1.584963
Log base 2 of 4.000000 is 2.000000
Log base 2 of 5.000000 is 2.321928
Log base 2 of 6.000000 is 2.584963
Log base 2 of 7.000000 is 2.807355
Log base 2 of 8.000000 is 3.000000
on my system.
PS: I slightly modified your [Dark_Helmet's] code to eliminate an error message (no return value for "main") and to process all the arguments internally. Like this at the end:
Code:
for (i=1; i < argc; ++i) {
given_value = strtod( argv[i], NULL );
log_base_2 = log2( given_value );
printf( "Log base 2 of %f is %f\n",
given_value,
log_base_2 );
}
return 0;
PPS: As you see, FC4 defines a
c99 script, which just calls
gcc with the
-std=c99 argument.