The (incorrect) output of the above is 'Testing 40 and 40.1 = 1'.
Does anyone know why the output is different in the above cases? I am aware that typically a header shouldn't contain an implementation but I believe it is justified in my particular case (and I don't think that is relevant to why the output is different).
C++ 17 has std::abs(double), however in C there is no function overload so you have abs(int), labs(longint), llabs(longlongint) for integers and fabs(double), fabsf(float), fabsl(longdouble) for floating point numbers
also, there are no namespaces
so, when you were doing abs(num1 - num2), you were calling ::abs(), that is abs(int)
perhaps should use fabs()
edit: misread the reference, seems that std::abs(double) exists from c++98