QString str="0.1";
double x = str.toDouble();//i get 0.1000000001 !!
x= 2*x;//i get 0.200000003
To copy to clipboard, switch view to plain text mode
is there a way to correct this?!
No, not with the standard floating point types anyway. This is an architectural problem caused by base2 floating point numbers. There's simply put, no way to fix it. How you respond to it depends on your needs.
Bookmarks