EDIT: to reproduce it, use this piece of code.
union
{
double d;
size_t s;
} d;
d.s = 0xfff8000000000000;
d.d = fabs(d.d);
std::cout << d.d << std::endl;
the output is
-1.#IND
EDIT: I do not agree this duplicated the other question, sqrt and abs are absolute different functions. When you send an negative value to sqrt, it may give you -Nan, but for abs, it should give you Nan.
I am using VS2013. A calculation function return -1.#IND000000000000 (hex 0xfff8000000000000) , which should mean -Nan in Visual studio and I use fabs() to get it's abs value, it still give me -1.#IND000000000000. I try use std::abs and get same result.
double x = some_function(...); // return -1.#IND000000000000
x = fabs(x);
// or
x = std::abs(x);
In http://en.cppreference.com/w/cpp/numeric/math/fabs it only mentioned fabs(-INF)=INF, nothing about NAN or IND. Is this a undefined behavior, or a bug in visual studio 2013?
-ffast-math
enabled; then all sorts of things get thrown out. Trying to do mathematical things on something that is quite literally Not a Number won't get you expected results. – Fund Monica's Lawsuit Feb 8 '17 at 22:45