summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-02-24 15:33:37 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-24 15:45:59 -0800
commitd753805542cf15a35000ca3b952c719a3470d388 (patch)
treeef81564c114ed6653b79fb5ccaebc8a9095963d6 /dive.h
parent7b20fb826c9f7ff2ad9d26526e6457a5b5d9b9d5 (diff)
downloadsubsurface-d753805542cf15a35000ca3b952c719a3470d388.tar.gz
Fix cylinder air size calculations
Commit 90d3c5614a9c ("Centralising and redefining values as integers") broke SAC-rate calculations. In particular, it changed "to_ATM()": to use the centralized SURFACE_PRESSURE helper define, but in the process it changed a floating point calculation to an integer calculation, and it threw away all the fractional details. Any user of "to_ATM()" basically dropped to an accuracy of a single atmosphere. The good news is that we didn't use to_ATM() for things like depth calculations, but only for cylinder pressures. As a result, the error ends up being relatively small, since the pressures involved are big, and thus the error of rounding to whole atmospheres is usually in the 1% range. The cylinder sizing tends to be off by more than that anyway. But it was wrong, and not intentional. 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.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/dive.h b/dive.h
index 1ad5a9599..727f03033 100644
--- a/dive.h
+++ b/dive.h
@@ -205,7 +205,7 @@ static inline double bar_to_atm(double bar)
static inline double to_ATM(pressure_t pressure)
{
- return pressure.mbar / SURFACE_PRESSURE;
+ return pressure.mbar / (double) SURFACE_PRESSURE;
}
static inline int mbar_to_PSI(int mbar)