From 8375e9a51b29a54e86fca3e923d8f1fb01910666 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Tue, 10 Jul 2012 02:20:04 +0200 Subject: Use integers rather than floats everywhere We don't need floating point precision if results are casted back to integer. Instead, rearrange operations and do the integer division after the multiplication. Version numbers are terminating decimals anyway and can be stored using two integers without losing any information. Signed-off-by: Lukas Fleischer --- src/wins.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/wins.c') diff --git a/src/wins.c b/src/wins.c index 2f04605..85666df 100644 --- a/src/wins.c +++ b/src/wins.c @@ -253,9 +253,8 @@ void wins_scrollwin_display(struct scrollwin *sw) const int visible_lines = sw->win.h - sw->pad.y - 1; if (sw->total_lines > visible_lines) { - float ratio = ((float)visible_lines) / ((float)sw->total_lines); - int sbar_length = (int)(ratio * visible_lines); - int highend = (int)(ratio * sw->first_visible_line); + int sbar_length = visible_lines * visible_lines / sw->total_lines; + int highend = visible_lines * sw->first_visible_line / sw->total_lines; int sbar_top = highend + sw->pad.y + 1; if ((sbar_top + sbar_length) > sw->win.h - 1) -- cgit v1.2.3-54-g00ecf