# "-l" parameter for 'bc' means using math library. pi=$(echo"scale=10; 4*a(1)" | bc -l) s=$(echo"s($pi/6)" | bc -l) echo"pi=$pi" echo"s=sin(pi/6)=$s"
# use more options of 'bc' tool r=$(echo'ibase=10;obase=2; 15+16' | bc) echo"binary of (15+16) is $r"
# comparison for floating point numbers using 'bc' big=100 small=99.9 if [ $(echo"$big > $small" | bc) -eq 1 ]; then echo"$big is bigger than $small" fi
# deal with floating point numbers with 'awk' language echo $(awk -v x=10 -v y=2.5 'BEGIN {printf "10/2.5=%.2f\n",x/y}') v=$(echo$big$small | awk '{ printf "%0.8f\n" ,$1/$2}') echo"$big / $small = $v"