summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-11-20 10:27:33 -0800
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-11-20 10:27:33 -0800
commita643e740dc32d474cc4f0ff3f0187418463e44e1 (patch)
tree17a17d070cab4f80e84ceb41231664455a375bfd /profile.c
parentbb421a416dd894979e2335efea8db06b681f0dc8 (diff)
downloadsubsurface-a643e740dc32d474cc4f0ff3f0187418463e44e1.tar.gz
Do proper rounding in interpolated pressure calculations
We do all the pressures in mbar, which has plenty of precision for interpolated pressures - even when we then do our discrete integration over many samples. However, when we calculate those interpolated pressure points, we should make sure that we round the result correctly, otherwise the consistent rounding errors (from truncating the FP value into our integer mbar values) will result in a final pressure that is noticeably off in ugly ways (ie "end pressure set by hand to 750 mbar, but shown as 748"). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/profile.c b/profile.c
index 5485ffdc2..aedea192b 100644
--- a/profile.c
+++ b/profile.c
@@ -1001,7 +1001,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
double cur_pt = (entry->sec - (entry-1)->sec) *
(1 + (entry->depth + (entry-1)->depth) / 20000.0);
INTERPOLATED_PRESSURE(entry) =
- cur_pr[entry->cylinderindex] + cur_pt * magic;
+ cur_pr[entry->cylinderindex] + cur_pt * magic + 0.5;
cur_pr[entry->cylinderindex] = INTERPOLATED_PRESSURE(entry);
} else
INTERPOLATED_PRESSURE(entry) = cur_pr[entry->cylinderindex];