diff --git a/gaboshlib/g_calc.sh b/gaboshlib/g_calc.sh index 7542913..763547e 100644 --- a/gaboshlib/g_calc.sh +++ b/gaboshlib/g_calc.sh @@ -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