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>
This commit is contained in:
Linus Torvalds 2013-01-23 12:33:26 -08:00 committed by Dirk Hohndel
parent aac44f9b07
commit 413b9026dd
2 changed files with 1 additions and 22 deletions

View file

@ -894,7 +894,7 @@ static void plot_single_temp_text(struct graphics_context *gc, int sec, int mkel
deg = get_temp_units(mkelvin, &unit);
plot_text(gc, &tro, sec, mkelvin, "%d%s", (int)(deg + 0.5), unit);
plot_text(gc, &tro, sec, mkelvin, "%.2g%s", deg, unit);
}
static void plot_temperature_text(struct graphics_context *gc, struct plot_info *pi)