swiety
22nd November 2007, 10:49
729194496 B = 695.4 MB
2x695.4 MB = 145838898 B = 1.35 GB
1 GB = 2^30 B = 1073741824 B
and now
QFileInfo file("movie.avi");
qint64 size = file.size(); // 729194496 B
size += size; // 145838898 B
double z = size/1073741824;
QString str;
str = QString::number( z, 'f', 2 ); // 1.00 ( WRONG )
str.sprint("%.2f", z ); //1.00
int x = floor( z ); // x = 1, qRound( z ) = 1 ( GOOD )
int y = floor( (z - x )*100 ); // y=0 ( WRONG )
str = QString::number(x)+"."+QString::number(y); //1.00 ( WRONG )
So, how can i get 1.35 GB ?
2x695.4 MB = 145838898 B = 1.35 GB
1 GB = 2^30 B = 1073741824 B
and now
QFileInfo file("movie.avi");
qint64 size = file.size(); // 729194496 B
size += size; // 145838898 B
double z = size/1073741824;
QString str;
str = QString::number( z, 'f', 2 ); // 1.00 ( WRONG )
str.sprint("%.2f", z ); //1.00
int x = floor( z ); // x = 1, qRound( z ) = 1 ( GOOD )
int y = floor( (z - x )*100 ); // y=0 ( WRONG )
str = QString::number(x)+"."+QString::number(y); //1.00 ( WRONG )
So, how can i get 1.35 GB ?