mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix double to int truncation in C++ code
Wfloat-conversion enabled for C++ part of the code Fix warnings raised by the flag using lrint Original issue reported on the mailing list: The ascent/descent rates are sometimes not what is expected. E.g. setting the ascent rate to 10m/min results in an actual ascent rate of 9m/min. This is due to truncating the ascent rate preference, then effectively rounding up the time to reach each stop to 2s intervals. The result being that setting the ascent rate to 10m/min results in 20s to ascend 3m (9m/min), when it should be exactly 18s. Reported-by: John Smith <noseygit@hotmail.com> Reported-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
This commit is contained in:
parent
d83449f3b5
commit
597539ce39
25 changed files with 73 additions and 72 deletions
|
@ -1566,7 +1566,7 @@ void DeviceThread::event_cb(dc_device_t *device, dc_event_type_t event, const vo
|
|||
|
||||
switch (event) {
|
||||
case DC_EVENT_PROGRESS:
|
||||
dt->progressCB(100.0 * (double)progress->current / (double)progress->maximum);
|
||||
dt->progressCB(lrint(100.0 * (double)progress->current / (double)progress->maximum));
|
||||
break;
|
||||
default:
|
||||
emit dt->error("Unexpected event recived");
|
||||
|
|
|
@ -157,8 +157,8 @@ void GpsLocation::newPosition(QGeoPositionInfo pos)
|
|||
gpsTracker gt;
|
||||
gt.when = pos.timestamp().toTime_t();
|
||||
gt.when += gettimezoneoffset(gt.when);
|
||||
gt.latitude.udeg = lrint(pos.coordinate().latitude() * 1000000);
|
||||
gt.longitude.udeg = lrint(pos.coordinate().longitude() * 1000000);
|
||||
gt.latitude.udeg = (int)(pos.coordinate().latitude() * 1000000);
|
||||
gt.longitude.udeg = (int)(pos.coordinate().longitude() * 1000000);
|
||||
addFixToStorage(gt);
|
||||
}
|
||||
}
|
||||
|
@ -612,8 +612,8 @@ void GpsLocation::downloadFromServer()
|
|||
|
||||
struct gpsTracker gt;
|
||||
gt.when = timestamp.toMSecsSinceEpoch() / 1000;
|
||||
gt.latitude.udeg = latitude.toDouble() * 1000000;
|
||||
gt.longitude.udeg = longitude.toDouble() * 1000000;
|
||||
gt.latitude.udeg = (int)(latitude.toDouble() * 1000000);
|
||||
gt.longitude.udeg = (int)(longitude.toDouble() * 1000000);
|
||||
gt.name = name;
|
||||
// add this GPS fix to the QMap and the settings (remove existing fix at the same timestamp first)
|
||||
if (m_trackers.keys().contains(gt.when)) {
|
||||
|
|
|
@ -775,7 +775,7 @@ int parseDurationToSeconds(const QString &text)
|
|||
hours = "0";
|
||||
minutes = numOnly;
|
||||
}
|
||||
secs = hours.toDouble() * 3600 + minutes.toDouble() * 60 + seconds.toDouble();
|
||||
secs = lrint(hours.toDouble() * 3600 + minutes.toDouble() * 60 + seconds.toDouble());
|
||||
return secs;
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,7 @@ int parseLengthToMm(const QString &text)
|
|||
return 0;
|
||||
double number = numOnly.toDouble();
|
||||
if (text.contains(QObject::tr("m"), Qt::CaseInsensitive)) {
|
||||
mm = number * 1000;
|
||||
mm = lrint(number * 1000);
|
||||
} else if (text.contains(QObject::tr("ft"), Qt::CaseInsensitive)) {
|
||||
mm = feet_to_mm(number);
|
||||
} else {
|
||||
|
@ -797,7 +797,7 @@ int parseLengthToMm(const QString &text)
|
|||
mm = feet_to_mm(number);
|
||||
break;
|
||||
case units::METERS:
|
||||
mm = number * 1000;
|
||||
mm = lrint(number * 1000);
|
||||
break;
|
||||
default:
|
||||
mm = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue