frawk
frawk copied to clipboard
Scientific notation is not supported in awk script.
Scientific notation is not supported in awk script, but works for parsing files with scientific notation.
$ printf '6.18163e-27\n1.80782e-40\n2.38296e-05\n1.92843e-09\n7.37465e-39\n' | frawk '$1 <= 1e-8'
$ printf '6.18163e-27\n1.80782e-40\n2.38296e-05\n1.92843e-09\n7.37465e-39\n' | frawk '$1 <= 1E-8'
$ printf '6.18163e-27\n1.80782e-40\n2.38296e-05\n1.92843e-09\n7.37465e-39\n' | frawk '$1 <= 10^-8'
6.18163e-27
1.80782e-40
1.92843e-09
7.37465e-39
# It understands scientific notation when parsing files itself.
$ printf '6.18163e-27\n1.80782e-40\n2.38296e-05\n1.92843e-09\n7.37465e-39\n' | frawk '{ if ($1 <= 10^-8) { print $1, ($1 + 0.0); } }'
6.18163e-27 6.18163e-27
1.80782e-40 1.80782e-40
1.92843e-09 1.92843e-9
7.37465e-39 7.37465e-39
$ printf '6.18163e-27\n1.80782e-40\n2.38296e-05\n1.92843e-09\n7.37465e-39\n' | gawk '$1 <= 1e-8'
6.18163e-27
1.80782e-40
1.92843e-09
7.37465e-39
$ printf '6.18163e-27\n1.80782e-40\n2.38296e-05\n1.92843e-09\n7.37465e-39\n' | gawk '$1 <= 1E-8'
6.18163e-27
1.80782e-40
1.92843e-09
7.37465e-39
$ printf '6.18163e-27\n1.80782e-40\n2.38296e-05\n1.92843e-09\n7.37465e-39\n' | gawk '$1 <= 10^-8'
6.18163e-27
1.80782e-40
1.92843e-09
7.37465e-39
Ah, good catch! This is a limitation of the regex used to identify if a numeric literal is a float or not. This ought to be a simple fix.
That latest commit should fix the bug