When you need to use the absolute value from a variable, use std::abs
(usually residing in std::fabs
.
If you only use ::abs
with floating point variables, you’ll risk an implicit cast to an integral value (short, int, long). This won’t be converted to std::abs even if you include using namespace std;
Be safe, use ::fabs, std::abs or std::fabs, but not ::abs
.
C++ Hello World