Here is some simple test code.
#!bin/bash cpm=(0 1 0.094) lv=1 attack=5 defense=9 stamina=16 echo $((cpm[lv])) mycpm=$((cpm[lv])) #mycpm=`echo "0.094" | bc -l` cq=`echo "$attack*$defense*1/10*sqrt($stamina)*2^2*$mycpm" | bc -l` echo $cq Terminal output:
bash testing.sh 1 72.00000000000000000000 Okay, great.
Then if I change the third line to lv=2
bash testing.sh testing.sh: line 7: 0.094: syntax error: invalid arithmetic operator (error token is ".094") testing.sh: line 8: 0.094: syntax error: invalid arithmetic operator (error token is ".094") (standard_in) 2: syntax error So how am I supposed to use decimals from an array? I cannot find any thing with duckduckgoing. The closest are links to for loop arrays where they figure out how to iterate by +0.1 each step. Otherwise its tutorials that all use integers. I have a preconstructed array and I just need to get values out of it to use in expressions.
Line 10 will work if I actually take out the $mycpm and change that to 0.094. It'll evaluate that just fine. It's just the problem if being able to use an array to have this value.
Is what I want to achieve possible in bash?