[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Overflow to Infinity
From: |
Andrew J. Schorr |
Subject: |
Re: [bug-gawk] Overflow to Infinity |
Date: |
Tue, 19 Jun 2018 20:33:06 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
On Tue, Jun 19, 2018 at 04:03:06PM -0700, Daniel Pettet wrote:
> Gawk is already supporting the '+inf' form within strings in awk source
> code.
>
> print +"+inf" # inf
> print +"+inf" + 5 # inf
> print +"-inf" # -inf
> print +"-inf" + 7 # -inf
>
> These illustrate my point and this could be supported when in user input
> data.
Actually, gawk does support +inf and -inf in user input. The only version it
does NOT support is plain old inf (or infinity). But it does work when --posix
is used. Using the gawk master branch:
bash-4.2$ (echo +inf; echo -inf; echo inf; echo +infinity; echo -infinity; echo
infinity) | ./gawk '{print $1+0}'
inf
-inf
0
inf
-inf
0
bash-4.2$ (echo +inf; echo -inf; echo inf; echo +infinity; echo -infinity; echo
infinity) | ./gawk --posix '{print $1+0}'
inf
-inf
inf
inf
-inf
inf
I believe this could be fixed by patching the
is_ieee_magic_val/get_ieee_magic_val
logic in node.c.
As before, I pass no judgement on whether it would be a good idea to make this
change. I do not pretend to be a language lawyer. :-)
Regards,
Andy
- Re: [bug-gawk] Overflow to Infinity, (continued)
Re: [bug-gawk] Overflow to Infinity, Daniel Pettet, 2018/06/19