mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
406e4287eb
commit
2b06a0b223
20 changed files with 109 additions and 100 deletions
|
@ -622,10 +622,10 @@ int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct
|
|||
/* Avoid negative depths */
|
||||
pressure_delta = tissues_tolerance > surface_pressure ? tissues_tolerance - surface_pressure : 0.0;
|
||||
|
||||
depth = rel_mbar_to_depth(pressure_delta * 1000, dive);
|
||||
depth = rel_mbar_to_depth(lrint(pressure_delta * 1000), dive);
|
||||
|
||||
if (!smooth)
|
||||
depth = ceil(depth / DECO_STOPS_MULTIPLIER_MM) * DECO_STOPS_MULTIPLIER_MM;
|
||||
depth = lrint(ceil(depth / DECO_STOPS_MULTIPLIER_MM) * DECO_STOPS_MULTIPLIER_MM);
|
||||
|
||||
if (depth > 0 && depth < buehlmann_config.last_deco_stop_in_mtr * 1000)
|
||||
depth = buehlmann_config.last_deco_stop_in_mtr * 1000;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue