Changeset 89 in tspsg-svn for trunk/src/tspmodel.cpp


Ignore:
Timestamp:
Jan 12, 2010, 4:27:52 PM (15 years ago)
Author:
laleppa
Message:

Back to double to maintain compatibility between platforms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tspmodel.cpp

    r87 r89  
    281281                for (int c = 0; c < nCities; c++)
    282282                        if (r != c) {
    283                                 ds << static_cast<double>(table[r][c]); // We cast to double because qreal may be float on some platforms and we store double values in file
     283                                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
    284284                                if (f.error() != QFile::NoError) {
    285285                                        f.close();
     
    312312                else {
    313313bool ok;
    314 qreal tmp = value.toReal(&ok);
     314double tmp = value.toDouble(&ok);
    315315                        if (!ok || tmp < 0)
    316316                                return false;
     
    399399        }
    400400
    401 double x; // We need this as qreal may be float on some platforms and we store double values in file
     401double x; // We need this as double may be float on some platforms and we store double values in file
    402402        // Travel costs
    403403        for (int r = 0; r < size; r++)
     
    447447        }
    448448        // Travel costs
    449 qreal val;
     449double val;
    450450        for (int r = 0; r < 5; r++)
    451451                for (int c = 0; c < 5; c++)
     
    469469}
    470470
    471 inline qreal CTSPModel::rand(int min, int max) const
    472 {
    473 qreal r;
     471inline double CTSPModel::rand(int min, int max) const
     472{
     473double r;
    474474        if (settings->value("Task/FractionalRandom", DEF_FRACTIONAL_RANDOM).toBool()) {
    475 qreal x = qPow(10, settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
    476                 r = (qreal)qRound((qreal)qrand() / RAND_MAX * (max - min) * x) / x;
     475double x = qPow(10, settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt());
     476                r = (double)qRound((double)qrand() / RAND_MAX * (max - min) * x) / x;
    477477        } else
    478                 r = qRound((qreal)qrand() / RAND_MAX * (max - min));
     478                r = qRound((double)qrand() / RAND_MAX * (max - min));
    479479        return min + r;
    480480}
Note: See TracChangeset for help on using the changeset viewer.