[LCP]Rounding questions

Chuck Martin nrocinu at myrealbox.com
Thu Sep 5 20:26:08 UTC 2002


On Thu, Sep 05, 2002 at 11:08:12AM +0100, Vincent Penquerc'h wrote:
> > Why is it rounding 390.0 and getting 2.896811?
> 
> Dunno. Try
> 
> double round(double x)
> {
>   return floor(x+0.5);
> }

That returns "390.000000", and is similar (but not exactly the same) to
what I was doing before that had a strange bug (apart from the fact that
that would have to be modified to work with negative numbers).

Chuck





More information about the linuxCprogramming mailing list