From 43d38ee5375bce563fdc8640fe6e916b64367247 Mon Sep 17 00:00:00 2001 From: olli Date: Wed, 15 Feb 2023 11:52:48 +0100 Subject: [PATCH] optimized function --- gaboshlib/g_percentage-diff.bashfunc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gaboshlib/g_percentage-diff.bashfunc b/gaboshlib/g_percentage-diff.bashfunc index 42ddbd3..af75ef5 100644 --- a/gaboshlib/g_percentage-diff.bashfunc +++ b/gaboshlib/g_percentage-diff.bashfunc @@ -3,6 +3,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./' | xargs printf "%.2f" + echo "scale=2; 100/$g_from*($g_to-$g_from)" | bc | sed 's/^\./0./; s/^-\./-0./' | xargs printf "%.2f" }