diff --git a/gaboshlib/g_calc.sh b/gaboshlib/g_calc.sh index 5ddffe8..7542913 100644 --- a/gaboshlib/g_calc.sh +++ b/gaboshlib/g_calc.sh @@ -39,13 +39,10 @@ function g_calc { [[ $g_calc_result == "-."* ]] && g_calc_result="-0.${g_calc_result#-.}" # remove ending 0 if for exabple 4.54300000 - if [[ $g_calc_result =~ [0-9]+\.[0-9]+ ]] - then - while [[ $g_calc_result =~ \.?[0-9]+0$ ]] - do - g_calc_result=${g_calc_result%0} - done - fi + while [[ $g_calc_result =~ [.] && ${g_calc_result: -1} == "0" ]] + do + g_calc_result=${g_calc_result: : -1} + done # check output if ! g_num_valid_number $g_calc_result