summaryrefslogtreecommitdiffstats
path: root/core/dive.h
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/dive.h
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/dive.h')
-rw-r--r--core/dive.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/dive.h b/core/dive.h
index 164886df6..981cdc0b9 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -499,7 +499,7 @@ static inline depth_t gas_mnd(struct gasmix *mix, depth_t end, struct dive *dive
pressure_t ppo2n2;
ppo2n2.mbar = depth_to_mbar(end.mm, dive);
- double maxambient = ppo2n2.mbar / (1 - get_he(mix) / 1000.0);
+ int maxambient = lrint(ppo2n2.mbar / (1 - get_he(mix) / 1000.0));
rounded_depth.mm = lrint(((double)mbar_to_depth(maxambient, dive)) / roundto) * roundto;
return rounded_depth;
}