This commit is contained in:
olli 2024-06-28 12:10:19 +02:00
parent 8a3654e42b
commit 26460cf7f5

View File

@ -39,13 +39,10 @@ function g_calc {
[[ $g_calc_result == "-."* ]] && g_calc_result="-0.${g_calc_result#-.}" [[ $g_calc_result == "-."* ]] && g_calc_result="-0.${g_calc_result#-.}"
# remove ending 0 if for exabple 4.54300000 # remove ending 0 if for exabple 4.54300000
if [[ $g_calc_result =~ [0-9]+\.[0-9]+ ]] while [[ $g_calc_result =~ [.] && ${g_calc_result: -1} == "0" ]]
then
while [[ $g_calc_result =~ \.?[0-9]+0$ ]]
do do
g_calc_result=${g_calc_result%0} g_calc_result=${g_calc_result: : -1}
done done
fi
# check output # check output
if ! g_num_valid_number $g_calc_result if ! g_num_valid_number $g_calc_result