summaryrefslogtreecommitdiffstats
path: root/statistics.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-02-09 10:23:15 +1100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-08 18:15:51 -0800
commitb286ea638c8ce468cf9c1a1b5037867acb5d6fe4 (patch)
treee6d593baf90d399b0532e0b6033905f219692483 /statistics.c
parentff969cd5c84824170b382901b49a97564bf72bfa (diff)
downloadsubsurface-b286ea638c8ce468cf9c1a1b5037867acb5d6fe4.tar.gz
Simplify/clarify the get_surface_pressure_in_mbar() function
Instead of maintaining a rolling average and re-calculating it at each stage, just calculate the surface_pressure average the natural way: as the sum divided by the number of entries. This results in a single rounding, rather than doing rounding multiple times and possibly rounding wrong as a result. Not that we care all that deeply about the LSB of the mbar value, but the code is simpler and more obvious this way too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r--statistics.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/statistics.c b/statistics.c
index 82070a937..d7abbc592 100644
--- a/statistics.c
+++ b/statistics.c
@@ -539,7 +539,7 @@ static void show_single_dive_stats(struct dive *dive)
double value;
int decimals;
const char *unit;
- int idx, offset, gas_used;
+ int idx, offset, gas_used, mbar;
struct dive *prev_dive;
struct tm tm;
@@ -579,8 +579,9 @@ static void show_single_dive_stats(struct dive *dive)
} else {
set_label(single_w.air_temp, "");
}
- if (get_surface_pressure_in_mbar(dive, FALSE)) {
- set_label(single_w.air_press, "%d mbar", dive->dc.surface_pressure.mbar);
+ mbar = get_surface_pressure_in_mbar(dive, FALSE);
+ if (mbar) {
+ set_label(single_w.air_press, "%d mbar", mbar);
} else {
set_label(single_w.air_press, _("unknown"));
}