CBFalconer wrote:
: Second the following shows the correct result: : #include <stdio.h> : #include <math.h> : : int main( void ) : { : long double R; : R = sin( 1.2345); : printf( "sizeof( long double) = %d\n", sizeof( long double)); : printf( "sin( 1.2345) = %.30f = %.30f\n", (double)R, (double)R); : return 0; : }
This program is correct. However `sin' returns a `double' (this
No it isn't. sizeof returns a size_t, which is not necessarily anything like an int, and is unsigned. The result should be cast to an unsigned long (in C90) and so treated in the format specification. I believe C99 has a %zu specifier available for size_t items. Similarly %td is available for ptrdiff_t items, which are signed, and which has no bearing on the above code.
You're right, I missed this one. (At least the statement with the doubles is right. ;-)
Frank