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
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue