Changeset e4ae9e95f7 in tspsg for src/tspmodel.cpp


Ignore:
Timestamp:
Jan 12, 2010, 4:27:52 PM (14 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
3e46075789
Parents:
fcd8c1e4c1
Message:

Back to double to maintain compatibility between platforms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tspmodel.cpp

    rfcd8c1e4c1 re4ae9e95f7  
    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.