aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkatherine <shmibs@shmibbles.me>2016-02-01 21:10:31 -0700
committerkatherine <shmibs@shmibbles.me>2016-02-01 21:10:31 -0700
commitb7bf00c5dc033406fd00d95e6a9dd8e663be3a4e (patch)
tree2c1484608cc3294a16139bd1ba35e1599f2250fc
parent8ec3a1d67c3fb8b35a3ad920e7208616d6a1f0a1 (diff)
downloaddotfiles-b7bf00c5dc033406fd00d95e6a9dd8e663be3a4e.tar.gz
rounding with calc
-rw-r--r--.zshrc-linux-desktop6
1 files changed, 3 insertions, 3 deletions
diff --git a/.zshrc-linux-desktop b/.zshrc-linux-desktop
index 28e251d..f92845b 100644
--- a/.zshrc-linux-desktop
+++ b/.zshrc-linux-desktop
@@ -43,8 +43,8 @@ mpd-filetypes() {
if [[ ${counts[$i]} -eq 0 ]]; then
percentages[$i]=0
else
- # dunno how to make zsh math float without appending a . to integer numbers
- percentages[$i]=$(calc -p "${counts[$i]} * 100 / $total" | tr -d '~' | cut -c -4)
+ percentages[$i]=$(calc -p "a=${counts[$i]} * 100 / $total; round(a, 4-digits(a), 16)"\
+ | tr -d '~')
fi
# get widths for padding.
@@ -70,7 +70,7 @@ mpd-filetypes() {
done
# print total
- linelen=$(( $twidth + $cwidth + 9 ))
+ linelen=$(( $twidth + $cwidth + 10 ))
for (( i=0; i < $linelen; i++ )); do
echo -n "="
done