Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scientific notation is not supported in awk script. #83

Open
ghuls opened this issue Jan 28, 2022 · 2 comments
Open

Scientific notation is not supported in awk script. #83

ghuls opened this issue Jan 28, 2022 · 2 comments

Comments

@ghuls
Copy link
Contributor

ghuls commented Jan 28, 2022

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
@ezrosent
Copy link
Owner

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.

ezrosent added a commit that referenced this issue Jan 30, 2022
This should address the bug identified in #83.
@ezrosent
Copy link
Owner

That latest commit should fix the bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants