summaryrefslogtreecommitdiffstats
path: root/core/units.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/units.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/units.h')
-rw-r--r--core/units.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/core/units.h b/core/units.h
index 029bb64fa..30d52fbf8 100644
--- a/core/units.h
+++ b/core/units.h
@@ -134,7 +134,7 @@ static inline double grams_to_lbs(int grams)
static inline int lbs_to_grams(double lbs)
{
- return rint(lbs * 453.6);
+ return lrint(lbs * 453.6);
}
static inline double ml_to_cuft(int ml)
@@ -159,12 +159,12 @@ static inline double m_to_mile(int m)
static inline unsigned long feet_to_mm(double feet)
{
- return rint(feet * 304.8);
+ return lrint(feet * 304.8);
}
static inline int to_feet(depth_t depth)
{
- return rint(mm_to_feet(depth.mm));
+ return lrint(mm_to_feet(depth.mm));
}
static inline double mkelvin_to_C(int mkelvin)
@@ -179,12 +179,12 @@ static inline double mkelvin_to_F(int mkelvin)
static inline unsigned long F_to_mkelvin(double f)
{
- return rint((f - 32) * 1000 / 1.8 + ZERO_C_IN_MKELVIN);
+ return lrint((f - 32) * 1000 / 1.8 + ZERO_C_IN_MKELVIN);
}
static inline unsigned long C_to_mkelvin(double c)
{
- return rint(c * 1000 + ZERO_C_IN_MKELVIN);
+ return lrint(c * 1000 + ZERO_C_IN_MKELVIN);
}
static inline double psi_to_bar(double psi)
@@ -194,12 +194,12 @@ static inline double psi_to_bar(double psi)
static inline long psi_to_mbar(double psi)
{
- return rint(psi_to_bar(psi) * 1000);
+ return lrint(psi_to_bar(psi) * 1000);
}
static inline int to_PSI(pressure_t pressure)
{
- return rint(pressure.mbar * 0.0145037738);
+ return lrint(pressure.mbar * 0.0145037738);
}
static inline double bar_to_atm(double bar)