[LCP]Rounding questions

Chuck Martin nrocinu at myrealbox.com
Mon Sep 9 19:06:05 UTC 2002


On Thu, Sep 05, 2002 at 06:36:26PM -0400, Mike & Penny wrote:
> > Thank you!  This works.  Do you happen to know why rint() works without
> > doing this?  I can't seem to find a prototype for it anywhere, including
> > math.h.
> >
> 
>  Chuck,
>      Here are some questions to ask yourself that might help explain:
> 
>     1) What is the type returned by rint?

double

>     2) What is the type returned by round?

double

>     3) What is the default (the type the compiler will assume is returned if
> it can't find a prototype for a function)?

int

>     4) What are the consequences of forgetting the prototype of a function
> that return integer?

nothing

>     5) What are the consequences of forgetting the prototype if the function
> does NOT return integer?

As the round() problems show, incorrect results.

>     Does that help?

Not really.  My question was that I saw no difference between round() and
rint(), so I don't understand why one works and the other doesn't.  Neither
has a prototype I can find, and both take the same type of arguments and
return the same type of results.

Chuck





More information about the linuxCprogramming mailing list