I want to have the absolute value of a long double
.
According to <cmath>
or <math.h>
, the following is available:
double fabs (double x);
float fabs (float x);
long double fabs (long double x);
However, when doing long double ld = fabs(static_cast<long double>(0));
, I get the following warning (LLVM 7.1):
Absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value
How come?
What other ways are there to get the absolute value of a long double
?
Edit:
std::abs
eventually did the job. However, std::fabs
didn't. As was pointed out in the comments, this may be due to a non-conforming implementation.