|
From: | Christian JULLIEN |
Subject: | [Tinycc-devel] RE :Re: sinf/sin problems |
Date: | Wed, 24 Dec 2014 14:41:10 +0100 (CET) |
----- message d'origine -----
De : "Daniel Glöckner" <address@hidden>
date mer. 24/12/2014 13:54 (GMT +01:00)
À : "address@hidden" <address@hidden>
Objet : Re: [Tinycc-devel] sinf/sin problems
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.000000. That's because of the ellipsis in the
declaration of printf.
Best regards,
Daniel
_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
[Prev in Thread] | Current Thread | [Next in Thread] |