I am running into conversion of string to numbers in awk that I can't understand and don't know how to deal with properly
My script checks for numeric only field, I use this approach to do that:
$1 + 0 == $1
It works most of the time, but in some cases it does not behave how I expect it to behave, for example for value 673E5 script wrongly assumes it is numeric.
Please see below a series of values and how it is converted, hope it makes my question clearer:
echo "67305"|awk '{s=$1+0==$1?"Eq":"No"; print $1 ";" $1+0 ";" s}'
67305;67305;Eq
echo "673N5"|awk '{s=$1+0==$1?"Eq":"No"; print $1 ";" $1+0 ";" s}'
673N5;673;No
echo "673E5"|awk '{s=$1+0==$1?"Eq":"No"; print $1 ";" $1+0 ";" s}'
673E5;67300000;Eq
I used both awk and gawk, same reaction.
See how last example is badly converted and compare comes back with positive somehow.
What do I do wrong?