I have written shell script to substract two float values For eg. below are the two values :
debit_amount=7.853117806000353E7
credit_amount=3223649.619999993
val1=$(printf "%f", "$debit_amount")
val2=$(printf "%f", "$credit_amount")
echo " val1 = " $val1
echo " val2 = " $val2
final=`echo "$val1-$val2" |bc`
Output :
val1 = 78531178.060004,
val2 = 3223649.620000,
(standard_in) 1: syntax error
I got the above error. I tried below commands as well
final=$(echo "$val1 - $val2"|bc)
echo "$(($val1-$val2))"
echo `expr $val1 - $val2`
However I am still getting syntax error. Am I missing anything?