[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk infinity issues
From: |
Andrew J. Schorr |
Subject: |
Re: gawk infinity issues |
Date: |
Fri, 6 Jan 2006 12:04:30 -0500 |
User-agent: |
Mutt/1.4.1i |
On Fri, Jan 06, 2006 at 10:38:05AM -0500, Andrew J. Schorr wrote:
> So my question
> is why not rewrite force_number to call strtod unless the string looks
> like one of the hexadecimal values that we want to exclude?
In other words, what's wrong with the attached patch? It seems to fix
the problem for me on all 3 of my platforms (linux x86 32 & 64 bits,
and solaris 8 sparc 32 bits). With the patch, the attached test script
notfinite.awk does not produce any output other than the sqrt warning:
$ ./gawk -f test/notfinite.awk
gawk: test/notfinite.awk:17: warning: sqrt: called with negative argument -1
But without the patch, I see the following on my linux boxes:
$ ./gawk -f test/notfinite.awk
gawk: test/notfinite.awk:17: warning: sqrt: called with negative argument -1
(sprintf(%f,nan) = nan) != (sprintf(%f,"nan"+0) = 0.000000)
(sprintf(%f,nan) = nan) != (sprintf(%f,"-nan"+0) = 0.000000)
(sprintf(%f,inf) = inf) != (sprintf(%f,"inf"+0) = 0.000000)
(sprintf(%f,-inf) = -inf) != (sprintf(%f,"-inf"+0) = 0.000000)
And under solaris, the unpatched version gives:
$ ./gawk -f test/notfinite.awk
gawk: test/notfinite.awk:17: warning: sqrt: called with negative argument -1
(sprintf(%f,NaN) = NaN) != (sprintf(%f,"NaN"+0) = 0.000000)
(sprintf(%f,Inf) = Inf) != (sprintf(%f,"Inf"+0) = 0.000000)
And I think the patch should allow the removal of gawk_strtod.
Regards,
Andy
P.S. I'm a bit concerned about locale-related issues that might affect
this test:
if ((*cp == '0') && ((*(cp+1) == 'x') || (*(cp+1) == 'X'))) {
On the other hand, isnondecimal seems to contain similar logic...
force_number.patch
Description: Text document
notfinite.awk
Description: Text document
- gawk infinity issues, Andrew J. Schorr, 2006/01/05
- Re: gawk infinity issues, Aharon Robbins, 2006/01/05
- Re: gawk infinity issues, Andrew J. Schorr, 2006/01/06
- Re: gawk infinity issues, Paul Eggert, 2006/01/06
- Re: gawk infinity issues, Andrew J. Schorr, 2006/01/06
- Re: gawk infinity issues, Paul Eggert, 2006/01/06
- Re: gawk infinity issues, John Cowan, 2006/01/06
- Re: gawk infinity issues, Andrew J. Schorr, 2006/01/07
Re: gawk infinity issues, Aharon Robbins, 2006/01/08