[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Off Topic : c++ function for rounding



William Jensen <jensenb@bodach.com> writes:

> Hey guys, 
> 
> I know this isn't the right list, but how would I even find the 'right list'
> for a c++ question?  I know about ceil and floor but those aren't what I'm
> after.  I'm looking for a function that will take 1.4 and make it 1, but 1.5
> or higher is 2.  Know what I mean?  Any built-in c++ function to do that?

double rint(double x);

Well, actually it's a C function (so are ceil and floor).

If you can't use rint for some reason, you can always #define a macro:

#define ROUND(x) (floor(x+0.5))

Hubert



Reply to: