[LCP]Rounding questions

Andrew Weaver Andrew.Weaver at tecnomen.fi
Fri Sep 6 17:01:05 UTC 2002


Steve, awe award winner! Well spotted.

On Thursday, September 05, 2002 8:37 PM, Steve Baker
[SMTP:ice at mama.indstate.edu] wrote:
>   It seems perplexing, but the problem is that round is not prototyped in
> math.h, or anywhere for that matter.  This is clearly a glibc maintainer
> issue.  Add to your program at the top:
> 
> double round(double);
> 
>   And you're good to go.  Unprototyped functions default to returning int,
but
> the round() function was no doubt pushing doubles onto the stack, but
printf()
> was probably pulling the data off the stack as ints. Stack strangness
ensues
> and you only stumble onto the right value every third argument I would
> surmise.  If I cared to know i386, I could probably give you a much better
> (and probably more correct) answer, but I'm a C programmer not an
assembler.
> 
>   This is a good reminder of why you have to prototype your functions!
> 
> 								- Steve
> 
> _______________________________________________
> This is the Linux C Programming List
> :  http://lists.linux.org.au/listinfo/linuxcprogramming List




More information about the linuxCprogramming mailing list