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: Eli Zaretskii
Subject: Re: [bug-gawk] Overflow to Infinity
Date: Fri, 13 Jul 2018 16:43:20 +0300

> From: address@hidden
> Date: Fri, 13 Jul 2018 06:28:17 -0600
> Cc: address@hidden, address@hidden,
>         address@hidden
> 
> > So the behavior will not really be like C, where NaN == NaN yields
> > zero, right?  I think this part of the C behavior makes no sense in
> > Awk.
> 
> Exactly the opposite. Right now, NaN values compare equal to each
> other, both for array sort ordering, and for ==.  That NaN and Infinity
> values in awk do not act like C doubles for the regular comparison
> operators (==, !=, <, etc.) is a source of confusion to users, and the
> questions about it have started becoming more frequent.

I don't understand what do you mean by "like C doubles for the regular
comparison operators".  I can tell what I was talking about: the fact
that _any_ comparison with a NaN always yields zero (a.k.a. "false").
So a < NaN => false, but also a >= NaN => false, and NaN == NaN => false. 
How can this make sense?  What kind of users will be confused by
deviations from this craziness?

In C, we just get what the underlying machine instructions (codified
by IEEE) give us, but Awk is a language that isn't required to follow
that, AFAIU.  E.g., we don't have QNaN and SNaN, and I hope never
will.  On top of that, Awk sometimes doesn't interpret strings like
numbers, so we have even more reasons to deviate from IEEE here.

If this is not a convincing reason, then I guess nothing could ever be.



reply via email to

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