"Despite producing floating point results. Bash does not support other type of arguments than integers, so you need to rather invoke external tools like bc for your math or stick to integers only." 4.5: syntax error: invalid arithmetic operator (error token is ".5") - but the code still seems to work, why? Usually I use the bc external tool to fix it, but now I have a function and I do not know where to use it exactly, can you help me?
#!/bin/bash
function crossProduct {
declare -a v1=("${!1}")
declare -a v2=("${!2}")
#Note: Can't pass by reference, so the global variable must be used
vectResult[0]=$(( (v1[1] * v2[2]) - (v1[2] * v2[1]) ))
vectResult[1]=$(( - ((v1[0] * v2[2]) - (v1[2] * v2[0])) ))
vectResult[2]=$(( (v1[0] * v2[1]) - (v1[1] * v2[0]) ))
}
vect1[0]=0.3
vect1[1]=-0.3
vect1[2]=0.1
vect2[0]=0.4
vect2[1]=0.9
vect2[2]=2.3
crossProduct vect1[@] vect2[@]
echo ${vectResult[0]} ${vectResult[1]} ${vectResult[2]}