Written by marcelpetrick
on May 9, 2019
Problem was that I initialized some doubles with 0.0 and then hoped that the imported values are assigned, which does not happen always. So a check was needed. But checking if(0.0 == x)
is a really bad idea. MinGW will tell you too (as other compilers).
So I was searching for a proper way to check against 0.0. And then I found a better idea: initialize with NaN and use the standard-check against this. Much better!
1 2 3 4 5 6 7 8 9 10 |
#include <limits> .. // init them with NaN to prevent later issues double x{std::numeric_limits<double>::quiet_NaN()}; .. if(isnan(x)) { qDebug() << "uninitialized"; // todom remove return false; } |
(addendum: I know, a variant would be the best to fix the given task.)