Use "rint()" instead of rounding manually with "+ 0.5"

rint() is "round to nearest integer", and does a better job than +0.5
(followed by the implicit truncation inherent in integer casting).  We
already used 'rint()' for values that could be negative (where +0.5 is
actively wrong), let's just make it consistent.

Of course, as is usual for the messy C math functions, it depends on the
current rounding mode.  But the default round-to-nearest is what we want
and use, and the functions that explicitly always round to nearest
aren't standard enough to worry about.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2014-02-12 14:19:53 -08:00 committed by Dirk Hohndel
parent 7ae05b4f71
commit 23baf20f56
8 changed files with 38 additions and 38 deletions

View file

@ -627,7 +627,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
magic = (interpolate.end - interpolate.start) / (double) interpolate.pressure_time;
/* Use that overall pressure change to update the current pressure */
cur_pr[cyl] = interpolate.start + magic * interpolate.acc_pressure_time + 0.5;
cur_pr[cyl] = rint(interpolate.start + magic * interpolate.acc_pressure_time);
}
INTERPOLATED_PRESSURE(entry) = cur_pr[cyl];
}