bash - awk read float precision: cannot read small floats, e.g. 4e-320 -
i cannot awk or gawk read small floats in scientific notation , interpret them correctly floating point numbers.
i want output numbers above small threshold awk.
example:
consider following input:
4 3e-20 4.5e-320 3 1e-10 i want threshold 1e-15, following:
echo -e "4\n3e-20\n4.5e-320\n3\n1e-10" | awk '$1 > 1e-15' which gives output:
4 4.5e-320 3 1e-10 of course, 4.5e-320 not pass 1e-15 threshold, awk , gawk fail reject it!
i looked (g)awk floating point precision. seems apply only arithmetic operations within awk.
so, replacing awk '$1 > 1e-15' gawk -v prec="double" '$1 > 1e-15' fails. fails prec="quad"
thus, conclude (g)awk not reading 4.5e-320 float, instead string?
i expected output awk version 3.1.5.
i output awk version 3.1.7.
you can force awk convert string number adding 0 it.
so try awk script instead:
printf '4\n3e-20\n4.5e-320\n3\n1e-10\n' | awk '$1+0 > 1e-15'
Comments
Post a Comment