I have two sample applications using the same library and the main difference between them is that one uses qt and the other application is a console application.
In the common library, I have this test code:
double test = 0.1;
double test2 = atof("2.13134");
double test3 = atof("1,12345");
The values if I use the non-qt application are:
test = 0.10000000000001
test2 = 2.1323399999999999998
test3 = 1 // This is the expected result using a ',' as delimitation character
But with the qt application:
test = 0.10000000000001
test2 = 2 // This is not expected!!!
test3 = 1.1234500000000000001
Is there any case where the behaviour of the 'atof' changes because qt?
,
is the decimal point character in many locales) - perhaps Qt is setting a non-default locale based on system settings? – Normativeatof
andstrtod
were locale-dependent. That's horrible. Until just a few years one had to set the C default user locale with g++ in Windows, because the locale support was botched. – Borax