aboutsummaryrefslogtreecommitdiffstats
path: root/core/dive.h
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2017-03-08 13:41:41 +0700
committerGravatar Jeremie Guichard <djebrest@gmail.com>2017-03-08 14:04:17 +0700
commit406e4287eb96e10ddfd22163f0e863e353470c68 (patch)
tree1a859821cdd37485b7d9ce4c0404f73fdf68e78b /core/dive.h
parent9c2619ea3bcf8a0ad40a758692c26a5aec350c7f (diff)
downloadsubsurface-406e4287eb96e10ddfd22163f0e863e353470c68.tar.gz
Change calls to rint into lrint avoiding conversion warnings
Using gcc option "-Wfloat-conversion" is useful to catch potential conversion errors (where lrint should be used). rint returns double and still raises the same warning, this is why this change updates all rint calls to lrint. In few places, where input type is a float, corresponding lrinf is used. Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'core/dive.h')
-rw-r--r--core/dive.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/dive.h b/core/dive.h
index ba92e1083..164886df6 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -173,7 +173,7 @@ static inline int interpolate(int a, int b, int part, int whole)
/* It is doubtful that we actually need floating point for this, but whatever */
if (whole) {
double x = (double)a * (whole - part) + (double)b * part;
- return rint(x / whole);
+ return lrint(x / whole);
}
return (a+b)/2;
}
@@ -440,7 +440,7 @@ static inline int calculate_depth_to_mbar(int depth, pressure_t surface_pressure
if (salinity < 500)
salinity += FRESHWATER_SALINITY;
specific_weight = salinity / 10000.0 * 0.981;
- mbar += rint(depth / 10.0 * specific_weight);
+ mbar += lrint(depth / 10.0 * specific_weight);
return mbar;
}
@@ -470,7 +470,7 @@ static inline int rel_mbar_to_depth(int mbar, struct dive *dive)
if (dive->dc.salinity)
specific_weight = dive->dc.salinity / 10000.0 * 0.981;
/* whole mbar gives us cm precision */
- cm = rint(mbar / specific_weight);
+ cm = lrint(mbar / specific_weight);
return cm * 10;
}
@@ -489,7 +489,7 @@ static inline depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit, struct d
depth_t rounded_depth;
double depth = (double) mbar_to_depth(po2_limit.mbar * 1000 / get_o2(mix), dive);
- rounded_depth.mm = rint(depth / roundto) * roundto;
+ rounded_depth.mm = lrint(depth / roundto) * roundto;
return rounded_depth;
}
@@ -500,7 +500,7 @@ static inline depth_t gas_mnd(struct gasmix *mix, depth_t end, struct dive *dive
ppo2n2.mbar = depth_to_mbar(end.mm, dive);
double maxambient = ppo2n2.mbar / (1 - get_he(mix) / 1000.0);
- rounded_depth.mm = rint(mbar_to_depth(maxambient, dive) / roundto) * roundto;
+ rounded_depth.mm = lrint(((double)mbar_to_depth(maxambient, dive)) / roundto) * roundto;
return rounded_depth;
}