bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Overflow to Infinity


From: arnold
Subject: Re: [bug-gawk] Overflow to Infinity
Date: Sun, 24 Jun 2018 00:09:09 -0600
User-agent: Heirloom mailx 12.4 7/29/08

Hi.

> > This thread had brought up two issues. Input is not getting converted
> > "correctly", and gawk can output "inf" and/or "nan" since it relies on
> > the output of the C library printf in such cases.
>
> I don't follow. As I understand it, the two issues both relate to input, not
> output:
>
> 1. Huge numeric values that cause strtod to overflow to inf or -inf were
> returning ERANGE, and gawk was treating this as an error and forcing the
> value to zero. 

This is issue #1.

> 2. String values of "inf" and "infinity" are converted to zero when
> not running with --posix, in contrast to +inf, -inf, +infinity, and -infinity,
> which are converted to inf or -inf as expected.

This is not an issue. When gawk behaves differently with or without --posix
it is generally intentional, and generally documented.  In this case,
it's explained in 
https://www.gnu.org/software/gawk/manual/html_node/POSIX-Floating-Point-Problems.html#POSIX-Floating-Point-Problems.

Issue #2 is that gawk can print "inf", which means it can output stuff
that it can't read back later:

        $ gawk 'BEGIN { print 2+2, -log(0) }'
        4 inf

It is this latter issue that I am choosing to not deal with at the moment.

> > Reseting errno won't hurt and should probably be done.
>
> I modified this to set errno = 0 in that case. Or do you prefer to have
> separate logic for 'errno == 0' and 'errno == ERANGE'? It now needlessly
> sets errno to 0 in the 'errno == 0' case, but that seemed less horrible
> than duplicating the other logic.

Yes, I think that's fine.

> > Andy, please update your patch and go ahead and push it to gawk-4.2-stable.
> > Let's use Daniel's code as a new test case also, once you've added in
> > your patch.  Can you handle that for me?
>
> I pushed it just now.

Looks good.

Much thanks,

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]