jeudi 4 juin 2020

awk: negative exponential is not correctly interpreted

I have this table:

a   0
b   0
c   1.6149e-315
d   5.2587e-265
e   8.2045e-227
f   8.2045e-227

If I type

$awk '($2<1){print}' my_file.txt

it returns

a   0
b   0
d   5.2587e-265
e   8.2045e-227
f   8.2045e-227

but it considers the value in the third row, 1.6149e-315, to be larger than 1:

$awk '($2>1){print}' my_file.txt 
c   1.6149e-315

Which is the reason for this behaviour? Is a negative exponential <1e-300 too small so it removes the "e-" part? It looks so, since

$awk '($2>1.6149){print}' my_file.txt 
c   1.6149e-315

but if I run

$ awk '($2>1.615){print}' my_file.txt

nothing is output.

How can I overcome this problem?

Aucun commentaire:

Enregistrer un commentaire