Fix potential double/float to int rounding errors

Not using lrint(f) when converting double/float to int
creates rounding errors.
This error was detected by TestParse::testParseDM4 failure
on Windows. It was creating rounding inconsistencies
on Linux too, see change in TestDiveDM4.xml.

Enable -Wfloat-conversion for gcc version greater than 4.9.0

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
This commit is contained in:
Jeremie Guichard 2017-03-09 23:07:30 +07:00
parent 406e4287eb
commit 2b06a0b223
20 changed files with 109 additions and 100 deletions

View file

@ -65,7 +65,7 @@ unsigned int get_distance(degrees_t lat1, degrees_t lon1, degrees_t lat2, degree
double c = 2 * atan2(sqrt(a), sqrt(1.0 - a));
// Earth radious in metres
return 6371000 * c;
return lrint(6371000 * c);
}
/* find the closest one, no more than distance meters away - if more than one at same distance, pick the first */