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

@ -127,7 +127,7 @@ static void put_cylinder_HTML(struct membuffer *b, struct dive *dive)
if (cylinder->type.size.mliter) {
int volume = cylinder->type.size.mliter;
if (prefs.units.volume == CUFT && cylinder->type.workingpressure.mbar)
volume *= bar_to_atm(cylinder->type.workingpressure.mbar / 1000.0);
volume = lrint(volume * bar_to_atm(cylinder->type.workingpressure.mbar / 1000.0));
put_HTML_volume_units(b, volume, "\"Size\":\"", " \", ");
} else {
write_attribute(b, "Size", "--", ", ");