I recently found that for some very small values, filtering using AWK doesn't seem to behave correctly. As in the following file test_loc.txt
:
10:10000018 10 0.4505
X:99997421 X 0.95508
X:99997626 X 0.016206
X:99998439 X 0.5043
10:100001724 10 0.69838
10:100001867 10 0.48936
2:137078930 2 2.8245e-05
10:100001868 10 0.11326
10:100002378 10 0.6674
19:45431453 19 3.952525e-323
10:100002464 10 0.87964
I want to filter by the third column, below some threshold. For instance:
awk '($3 < 0.5) {print $0}' test_loc.txt
yields
10:10000018 10 0.4505
X:99997626 X 0.016206
10:100001867 10 0.48936
2:137078930 2 2.8245e-05
10:100001868 10 0.11326
notably omitting the second to last entry, 19:45431453
with the very small column 3 value 3.952525e-323
.
However, when I threshold lower, at say 5e-5
:
awk '($3 < 5e-5) {print $0}' test_loc.txt
It picks it right up.
2:137078930 2 2.8245e-05
19:45431453 19 3.952525e-323
Any thoughts as to why and how I might get around this?
$3
or the number0.5
?) Tryawk '($3 + 0.0 < 0.5) {print $3}'
to make explicit that the left argument of<
is a number.-M
(--bignum
) option, to enable GMP supportGNU Awk 5.0.1
, even without-M
. Which version are you using?