This commit is contained in:
olli 2024-07-02 17:45:12 +02:00
parent 26460cf7f5
commit 3c42aff8f5

View File

@ -34,7 +34,7 @@ function g_calc {
return 1
fi
# fix bc outpur -> change for example .224 to 0.224 and -.224 to -0.224
# fix bc output -> change for example .224 to 0.224 and -.224 to -0.224
[[ $g_calc_result == "."* ]] && g_calc_result="0$g_calc_result"
[[ $g_calc_result == "-."* ]] && g_calc_result="-0.${g_calc_result#-.}"
@ -44,6 +44,9 @@ function g_calc {
g_calc_result=${g_calc_result: : -1}
done
# remove ending . for example "100." -> 100
[[ $g_calc_result == *"." ]] && g_calc_result=${g_calc_result%?}
# check output
if ! g_num_valid_number $g_calc_result
then