문제

The following command

echo 1.8e-308 | gawk '$1<0.05'

produce no output, while this one

gawk 'BEGIN{if(8.2547e-309<0.05){print "true"}}'

print "true".

This answer explain why the first command produce no otuput.

A possible workaround is

echo 1.8e-308 | awk '$1+0 < 0.05 {print}'

My question is: there is a better solution? For example some wrapper of awk that allow not to modify each script.

The optimal solution possibly would not require to recompile awk to use mpfr library.

도움이 되었습니까?

해결책

Try the following:

echo 1.8e-308 | gawk '($1+0)<0.05'

produces:

1.8e-308

Some other interesting observations:

echo "True" | gawk '1.8e-308<0.05'

gives

True

and

echo "True" | gawk '1.8e-322<1.9e-322'

gives

True

whereas

echo "True" | gawk '1.8e-323<1.9e-323'

gives nothing..

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top