summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-05-23 14:26:27 +0200
committerYorhel <git@yorhel.nl>2021-05-23 14:26:29 +0200
commitebeee7be01d9331141d5fb9bc56005d4845b8b6e (patch)
tree0d3bfec02a181fd4bee692b7bb4119b1b45fe6e1
parenta6b4aead43cf7ecaa3f4d01503244a13e67b3f09 (diff)
browser.c: Fix bar width floating point calculation
In some cases the bar width may be 1 block short due to imprecise floating point calculations. i.e. (max_width * a) / a != max_width, whereas (max_width * (a/a)) == max_width. Or, at least, that's what I've observed so far.
-rw-r--r--src/browser.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/browser.c b/src/browser.c
index a223b84..28d120e 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -160,7 +160,7 @@ static void browse_draw_graph(struct dir *n, int *x) {
/* graph (10+ columns) */
if(graph == 1 || graph == 3) {
uic_set(c == UIC_SEL ? UIC_GRAPH_SEL : UIC_GRAPH);
- o = (int)((float)bar_size*(float)(show_as ? n->asize : n->size) / (float)(show_as ? dirlist_maxa : dirlist_maxs));
+ o = (int)((float)bar_size*((float)(show_as ? n->asize : n->size) / (float)(show_as ? dirlist_maxa : dirlist_maxs)));
for(i=0; i<bar_size; i++)
addch(i < o ? '#' : ' ');
}