fixes
This commit is contained in:
parent
f5af07290e
commit
855352bdf4
@ -25,8 +25,20 @@ function g_calc {
|
||||
# send calculation and read result
|
||||
echo "$1" >&${g_fd_bc_in}
|
||||
read -u ${g_fd_bc_out} g_calc_result
|
||||
g_calc_result=${g_calc_result//-./-0.}
|
||||
g_calc_result=${g_calc_result//./0.}
|
||||
|
||||
# check if there is a output
|
||||
if [ -z $g_calc_result ]
|
||||
then
|
||||
echo "${FUNCNAME} $@" 1>&2
|
||||
unset g_calc_result
|
||||
return 1
|
||||
fi
|
||||
|
||||
# fix bc outpur -> 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#-.}"
|
||||
|
||||
# check output
|
||||
if ! g_num_valid_number $g_calc_result
|
||||
then
|
||||
echo "${FUNCNAME} $@" 1>&2
|
||||
|
Loading…
Reference in New Issue
Block a user