I am surprised with behaviour of awk
while performing floating point calculations. It lead me to wrong calculation on table data.
$ awk 'BEGIN {print 2.3/0.1}'
23 <-- Ok
$ awk 'BEGIN {print int(2.3/0.1)}'
22 <-- Wrong!
$ awk 'BEGIN {print 2.3-2.2==0.1}'
0 <-- Surprise!
$ awk 'BEGIN {print 2.3-2.2>0.1}' <-- Din't produce any output :(
$ awk 'BEGIN {print 2.3-2.2<0.1}'
1 <-- Totally confused now ...
Can somebody throw light as to what's happing here?
EDIT 1
As pointed by @fedorqui, output of second last command goes to file named 0.1 because of redirection operator (>).
Then how am I supposed to perform greater than (>) operation?
Solution to it is also given by @fedorqui
$ awk 'BEGIN {print (2.3-2.2>0.1)}'
0 <-- Wrong!