summaryrefslogtreecommitdiffstats
path: root/core/gaspressures.c
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2017-03-09 23:07:30 +0700
committerGravatar Jeremie Guichard <djebrest@gmail.com>2017-03-09 23:07:30 +0700
commit2b06a0b2234cf2779f80e87038011067be282bcb (patch)
tree7532b11736a5eaedb3ceddf3e85ee423948d47ce /core/gaspressures.c
parent406e4287eb96e10ddfd22163f0e863e353470c68 (diff)
downloadsubsurface-2b06a0b2234cf2779f80e87038011067be282bcb.tar.gz
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>
Diffstat (limited to 'core/gaspressures.c')
-rw-r--r--core/gaspressures.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/gaspressures.c b/core/gaspressures.c
index e74f26d3b..146086483 100644
--- a/core/gaspressures.c
+++ b/core/gaspressures.c
@@ -137,7 +137,7 @@ static void fill_missing_segment_pressures(pr_track_t *list, enum interpolation_
pt += list->pressure_time;
pressure = start;
if (pt_sum)
- pressure -= (start - end) * (double)pt / pt_sum;
+ pressure -= lrint((start - end) * (double)pt / pt_sum);
list->end = pressure;
if (list == tmp)
break;