Hi,

I have to get a value from a database, for example, 2.3000. Must compare this value with the result of this calculation, as code:

Qt Code:
  1. ...
  2. double y = 2.3;
  3. double x = qry.value(0).toDouble(); // Take 2.30000 in the database, this example;
  4.  
  5. qDebug() << y << x; // Ok, show 2.3 value for x and y;
  6.  
  7. double z = x - y; // It's result in -2.66454e-15!
  8.  
  9. if (z < 0.00) {
  10. ...
  11. }
  12. else
  13. {
  14. ...
  15. }
To copy to clipboard, switch view to plain text mode 

If I make a calculation explicitly declare the values for the variables x and y, result is correct.
I created a method to convert a QString to a double that is working (code below). Any hint to resolve this as I use this function to work around the problem?

Qt Code:
  1. ...
  2. double y = 2.3;
  3. QString sx = qry.value(0).toString();
  4.  
  5. double x = myfunction->toDouble(sx);
  6. double z = x - y; // It's OK, result 0
  7. ...
To copy to clipboard, switch view to plain text mode 

Thanks,

Marcelo Estanislau Geyer