Re: [Tinycc-devel] sinf/sin problems

2014-12-24 Thread Daniel Glöckner
Hi,

just some nit-picking:

On Wed, Dec 24, 2014 at 04:46:14PM +0800, Lee Duhem wrote:
 `sinf' is defined in libm.so, you need to link with it.

on Linux

 As explained by Aharon, c compiler will offer an implicit declaration
 for any undeclared function that it saw, and the return type of this
 implicit declaration is `int'. Therefore those return values of `sin'
 in your code will be converted to `int' first, then convert to `double'
 for `printf' to print.

The return value of a function returning an int is not passed in the
register where a double would be returned, so you might get garbage
that is in no way related to the input.

On top of that the int is not cast to double in
printf(\n%f, sin(1.0));
The bytes on the stack are simply reinterpreted as double, so
printf(%f\n, 1);
will not print 1.00.  That's because of the ellipsis in the
declaration of printf.

Best regards,

  Daniel

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] RE :Re: sinf/sin problems

2014-12-24 Thread Christian JULLIEN
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel