I am comparing the floating point values in shell script based on this reference. Following is the script contents
num1=50.960
num2=6.65E+07
echo "${num1} < ${num2}" | bc
When I ran the script the output is '0'. But according to the comparison it should be '1'. I need inputs on why the comparison is not working as expected ?
bc
treats6.65E
as6.659
. If it treated6.65E
as a hex number, I'd expect it to yield 6.39794921875 (seeprintf '%.15g\n' 0x6.65E
) – Stéphane Chazelas Mar 16 '21 at 11:15E
in the number somehow. In any case, it's not doing what the user want it to. – Kusalananda Mar 16 '21 at 11:19