Rounding shouldn't occur with those values and the double type. Are you sure you are not using float?
Try running this app:
#include <QtCore>
#include "stdio.h"
int main(){
str << "100001" << "10000.5" << "1000.55";
printf("%f\n", s.toDouble());
}
return 0;
}
#include <QtCore>
#include "stdio.h"
int main(){
QStringList str;
str << "100001" << "10000.5" << "1000.55";
foreach(const QString &s, str){
printf("%f\n", s.toDouble());
}
return 0;
}
To copy to clipboard, switch view to plain text mode
It gives me:
$ ./tst
100001.000000
10000.500000
1000.550000
Actually it works correctly with floats as well...
#include <QtCore>
#include <QtDebug>
int main(){
str << "100001" << "10000.5" << "1000.55";
double d = s.toDouble();
float f = s.toDouble();
qDebug() << d << f;
}
return 0;
}
#include <QtCore>
#include <QtDebug>
int main(){
QStringList str;
str << "100001" << "10000.5" << "1000.55";
foreach(const QString &s, str){
double d = s.toDouble();
float f = s.toDouble();
qDebug() << d << f;
}
return 0;
}
To copy to clipboard, switch view to plain text mode
yields:
$ ./tst
100001 100001
10000.5 10000.5
1000.55 1000.55
Bookmarks