summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-01-23 12:33:26 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-23 12:55:39 -0800
commit413b9026dd01e81cf804db27f8b0c06c48e833e2 (patch)
treefd1a82aa57a0f2b376399a682071a30a54c99415 /dive.h
parentaac44f9b0740726dd9d8cc9cce80b2e99626d0e1 (diff)
downloadsubsurface-413b9026dd01e81cf804db27f8b0c06c48e833e2.tar.gz
Fix temperature rounding issues
Temperatures can actually be negative, which means that rounding by adding 0.5 and casting to 'int' is not correct. We could use '(int)(rint(val))' instead, but the only place we care about might as well just print out the floating point representation with a precision of two digits instead. So if you have a dive computer that gives you the precision, you might see '3.5˚C' as the temperature. Remove the helper functions that nobody uses and that get the rounding wrong anyway. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h21
1 files changed, 0 insertions, 21 deletions
diff --git a/dive.h b/dive.h
index e76b6dadf..fc82f5e43 100644
--- a/dive.h
+++ b/dive.h
@@ -179,27 +179,6 @@ static inline unsigned long C_to_mkelvin(double c)
return c * 1000 + 273150.5;
}
-static inline int to_C(temperature_t temp)
-{
- if (!temp.mkelvin)
- return 0;
- return mkelvin_to_C(temp.mkelvin) + 0.5;
-}
-
-static inline int to_F(temperature_t temp)
-{
- if (!temp.mkelvin)
- return 0;
- return mkelvin_to_F(temp.mkelvin) + 0.5;
-}
-
-static inline int to_K(temperature_t temp)
-{
- if (!temp.mkelvin)
- return 0;
- return (temp.mkelvin + 499)/1000;
-}
-
static inline double psi_to_bar(double psi)
{
return psi / 14.5037738;