I assume that abs and fabs are behaving different when using math.h. But when I use just cmath and std::abs, do I have to use std::fabs or fabs? Or isn’t this defined?
I assume that abs and fabs are behaving different when using math.h . But
Share
In C++, it’s always sufficient to use
std::abs; it’s overloaded for all the numerical types.In C,
absonly works on integers, and you needfabsfor floating point values. These are available in C++ (along with all of the C library), but there’s no need to use them.