I'm trying to compare two floats in bash and something is going wrong. Here is the code sample based on solution herenum1=0.502E-01num2=0.01echo $num1'>'$num2 | bc -lecho $num2'>'$num1 | bc -lI expect the output of 1 for first echo and 0 for second echo, but instead I get 0 for the first and 1 for the second. What is wrong with this input? How to get consistent comparison of these floats?
Wrong output in comparing floats
awk;bc;floating point
awk can certainly do float comparisons if called from your shell script.num1=0.502E-01num2=0.01awk -v a=$num1 -v b=$num2 'BEGIN{print(a>b)}'1awk -v a=$num1 -v b=$num2 'BEGIN{print(b>a)}'0