Hello, I'm a rookie in C++. Is there any function that rounds a number (ex. 5.67-->6)
Thanks
Printable View
Hello, I'm a rookie in C++. Is there any function that rounds a number (ex. 5.67-->6)
Thanks
Don't feel like a rookie, I don't know the C++ way either (or maybe I'm a rookie myself ;) )
The "C" way is to use something like the following:
Code:#include <math.h>
long round(double val)
{
return static_cast<long>(floor(val + 0.5));
}
Thanks for the tip!! See ya!:DQuote:
Originally posted by Yves M
Don't feel like a rookie, I don't know the C++ way either (or maybe I'm a rookie myself ;) )
The "C" way is to use something like the following:
Code:#include <math.h>
long round(double val)
{
return static_cast<long>(floor(val + 0.5));
}