bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Gawk and NaN values


From: Aharon Robbins
Subject: Re: [bug-gawk] Gawk and NaN values
Date: Sat, 12 Nov 2011 21:33:09 +0200
User-agent: Heirloom mailx 12.4 7/29/08

Hi. I've just re-read this discussion again.  It would boil down
to gawk having to have special case code to notice that a value
is a NaN and then put a leading sign on it in the output.  This
is probably not a major change, but it means more documentation work,
and I'm wondering if it's a big issue in practice.

Hermann - is this affecting your getting real work done?  Or did you
just happen to notice that gawk can output something that it won't
accept as the corresponding input?

Thanks,

Arnold

> Date: Wed, 31 Aug 2011 21:39:30 +0200
> From: Hermann Peifer <address@hidden>
> To: "Nelson H. F. Beebe" <address@hidden>
> Cc: "address@hidden" <address@hidden>
> Subject: Re: [bug-gawk] Gawk and NaN values
>
> Nelson,
>
> Thanks for your feedback. You wrote:
> >
> > Notice that the sign of an input NaN is always optional, and
> > scripting language implementations should certainly not
> > behave differently, because most are themselves implemented
> > in the C language.
> >
>
> As stated in the GAWK manual on p.346, the leading sign is not optional 
> for GAWK, but acts a signal to gawk that the value is really numeric...
>
> I gave the example:
>
> $ echo "1 -nan" | gawk '{print $1, $1/$2}' | gawk '{ print $1/$2 }'
> awk: cmd. line:1: (FILENAME=- FNR=1) fatal: division by zero attempted
>
> Obviously, the error can be avoided by using the --posix switch:
>
> $ echo "1 -nan" | gawk '{print $1, $1/$2}' | gawk --posix '{print $1/$2}'
> nan
>
> However, my main issue was that gawk is able to identify -nan as a 
> special Not-a-Number value, gawk does some calculations and then 
> produces an output value which it can't identify as a special value (at 
> least not without the --posix switch).
>
> Hermann



reply via email to

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