aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-10-07 21:39:20 +0300
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-10-09 13:38:58 +0300
commit56e755b7119b494d2d875c617500d0299ae06a35 (patch)
tree72a87c14e54d66465067eab60ec1a07016c39da5 /mobile-widgets/qmlmanager.cpp
parentf5f2754b81a6396a681d8aec7eb7bcde3c7ed879 (diff)
downloadsubsurface-56e755b7119b494d2d875c617500d0299ae06a35.tar.gz
Use lrint() for all degrees_t related rounding
In certain places the '(int)' cast is used, while in other the llrint() or lrint() functions. Make the conversation from degrees in the 'double' form to the 'int' degrees_t consistent using lrint(). lrint() is the function which should give the best results, because it accepts a 'double' and results in a 'long' even if degrees_t is 'int'. If the truncation from 'long' to 'int' is discarding some of the precision then the next step would be to turn degrees_t into a 64bit signed integer type. Possible fix for #625. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r--mobile-widgets/qmlmanager.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 7305166e8..dc37fd4b0 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -654,12 +654,12 @@ void QMLManager::refreshDiveList()
static void setupDivesite(struct dive *d, struct dive_site *ds, double lat, double lon, const char *locationtext)
{
if (ds) {
- ds->latitude.udeg = (int) (lat * 1000000);
- ds->longitude.udeg = (int) (lon * 1000000);
+ ds->latitude.udeg = lrint(lat * 1000000);
+ ds->longitude.udeg = lrint(lon * 1000000);
} else {
degrees_t latData, lonData;
- latData.udeg = (int) lat;
- lonData.udeg = (int) lon;
+ latData.udeg = lrint(lat);
+ lonData.udeg = lrint(lon);
d->dive_site_uuid = create_dive_site_with_gps(locationtext, latData, lonData, d->when);
}
}