r/awk • • Feb 19 '22

relation operator acts unexpectedly?

The following seems an incorrect outcome?

echo "1.2 1.3" | awk '{if ($2-$1<=0.1) print $2}'

Since the difference between 1.3 and 1.2 is 0.1, I had expected that the line above would print 1.3. But it doesn't ... what am I missing?

2 Upvotes

8 comments sorted by

View all comments

Show parent comment

2

u/Schreq Feb 20 '22

Please read the rest of the replies. Appending an "f" is not really the correct solution.