Changeset 89 in tspsg-svn for trunk/src/tspmodel.cpp
- Timestamp:
- Jan 12, 2010, 4:27:52 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tspmodel.cpp
r87 r89 281 281 for (int c = 0; c < nCities; c++) 282 282 if (r != c) { 283 ds << static_cast<double>(table[r][c]); // We cast to double because qrealmay be float on some platforms and we store double values in file283 ds << static_cast<double>(table[r][c]); // We cast to double because double may be float on some platforms and we store double values in file 284 284 if (f.error() != QFile::NoError) { 285 285 f.close(); … … 312 312 else { 313 313 bool ok; 314 qreal tmp = value.toReal(&ok);314 double tmp = value.toDouble(&ok); 315 315 if (!ok || tmp < 0) 316 316 return false; … … 399 399 } 400 400 401 double x; // We need this as qrealmay be float on some platforms and we store double values in file401 double x; // We need this as double may be float on some platforms and we store double values in file 402 402 // Travel costs 403 403 for (int r = 0; r < size; r++) … … 447 447 } 448 448 // Travel costs 449 qrealval;449 double val; 450 450 for (int r = 0; r < 5; r++) 451 451 for (int c = 0; c < 5; c++) … … 469 469 } 470 470 471 inline qrealCTSPModel::rand(int min, int max) const472 { 473 qrealr;471 inline double CTSPModel::rand(int min, int max) const 472 { 473 double r; 474 474 if (settings->value("Task/FractionalRandom", DEF_FRACTIONAL_RANDOM).toBool()) { 475 qrealx = qPow(10, settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());476 r = ( qreal)qRound((qreal)qrand() / RAND_MAX * (max - min) * x) / x;475 double x = qPow(10, settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt()); 476 r = (double)qRound((double)qrand() / RAND_MAX * (max - min) * x) / x; 477 477 } else 478 r = qRound(( qreal)qrand() / RAND_MAX * (max - min));478 r = qRound((double)qrand() / RAND_MAX * (max - min)); 479 479 return min + r; 480 480 }
Note: See TracChangeset
for help on using the changeset viewer.