|
-
May 21st, 2003, 09:12 AM
#1
Round in C++ ??
Hello, I'm a rookie in C++. Is there any function that rounds a number (ex. 5.67-->6)
Thanks
-
May 21st, 2003, 09:20 AM
#2
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));
}
Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
Supports C++ and VB out of the box, but can be configured for other languages.
-
May 21st, 2003, 10:02 AM
#3
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));
}
Thanks for the tip!! See ya!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|