round() for float in C++
Editor’s Note: The following answer provides a simplistic solution that contains several implementation flaws (see Shafik Yaghmour’s answer for a full explanation). Note that C++11 includes std::round, std::lround, and std::llround as builtins already. There’s no round() in the C++98 standard library. You can write one yourself though. The following is an implementation of round-half-up: double … Read more