[LCP]Rounding questions
Muli Ben-Yehuda
mulix at actcom.co.il
Thu Sep 5 20:01:07 UTC 2002
On Thu, Sep 05, 2002 at 05:45:44AM -0400, Chuck Martin wrote:
> On Thu, Sep 05, 2002 at 10:12:55AM +0100, Vincent Penquerc'h wrote:
> > You've linked libm.a in, did you (-lm) ?
>
> Thanks. How did I miss the obvious? The results are still strange:
>
> chuck at zeta:~$ cat roundtest.c
> #include <stdio.h>
> #include <math.h>
>
> int main()
> {
> printf("%f\n", round((double) 390.0));
> }
> chuck at zeta:~$ gcc -lm -o roundtest roundtest.c
> chuck at zeta:~$ ./roundtest
> 2.896811
> chuck at zeta:~$
>
> Why is it rounding 390.0 and getting 2.896811?
because round returns a double and you're printing a float...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.linux.org.au/pipermail/linuxcprogramming/attachments/20020905/8ebacaaf/attachment.pgp
More information about the linuxCprogramming
mailing list