Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Not Evaluated
-
Resolution: Done
-
Affects Version/s: 5.6.1
-
Fix Version/s: 5.7.0
-
Component/s: Core: QString and Unicode
-
Labels:None
-
Environment:Windows 7
-
Commits:8c2ca33073f20e1fe552bd8b5f663aec5b8a634d
Description
Converting a QVariant to double through "toDouble()" works differently for different values.
Consider the following piece of code:
QString value_1 = qs("30.45"); QVariant variant_1(value_1); QString converted_value_1 = variant_1.toString(); //string value is "30.45" double double_value_1 = variant_1.toDouble(); qDebug() << "Double value " << double_value_1;
------------> Value printed is "30.4499999999"
QString value_2 = qs("40.45"); QVariant variant_2(value_2); QString converted_value_2 = variant_2.toString(); //string value is "40.45" double double_value_2 = variant_2.toDouble(); qDebug() << "Double value " << double_value_2;
------------> Value printed is "40.4500000003"
I am not sure if this conversion is platform (OS) dependent.
I am debugging in Windows (Visual studio 13)