C++ 1-Liner: round() your numbers
C++, Programming March 23rd, 2009You know what really hurts? A missing round() function if you really need it. Here is a code snippet for all of those with the same problem.
-
template <class T>
-
inline T round(float num)
-
{
-
return static_cast<T>((num>0.0f) ? num+0.5f : num-0.5f);
-
}





Recent Comments