round to two places

This commit is contained in:
olli 2023-01-18 10:42:15 +01:00
parent 4b6f4b8341
commit 66f1f5f74c

View File

@ -4,5 +4,5 @@ function g_percentage-diff {
local g_from=$1
local g_to=$2
local g_diff=$(echo "scale=8; $g_to-$g_from" | bc | sed 's/^\./0./; s/^-\./-0./')
echo "scale=8; 100/$g_from*$g_diff" | bc | sed 's/^\./0./; s/^-\./-0./'
echo "scale=8; 100/$g_from*$g_diff" | bc | sed 's/^\./0./; s/^-\./-0./' | xargs printf "%.2f"
}