bug-gawk
[Top][All Lists]
Advanced

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

Re: "-nan + 0" Problem in inf-nan-torture unit test might result in chec


From: Nelson H. F. Beebe
Subject: Re: "-nan + 0" Problem in inf-nan-torture unit test might result in check failure
Date: Fri, 2 Sep 2022 08:41:43 -0600

Weisson Han reports on this list today about a failure of tests of
gawk on RISC-V64 on QEMU (an environment that I run here at Utah as
well, with Ubuntu, Fedora, and FreeBSD O/Ses):

>> The inf-nan-torture.awk expects that "-nan + 0 = -nan"
>> but the vm turned out "-nan + 0 = nan".

Since its design in the late 1970s, the IEEE 754 has always maintained
that the sign of a NaN has NO SIGNIFICANCE WHATEVER, and
implementations are free to produce any sign that suits them.

Extensive experience on all of the CPU types of the last four decades
that implement IEEE 754 arithmetic confirms that you cannot expect any
particular sign of a NaN from a numerical computation, so you should
ignore any cross-platform differences.

If you want to force a particular sign, you can always do so in
C/C++/... with copysign(x, +1.0) or copysign(x, -1.0).

Perhaps a revision of the gawk test is in order, but it is
certainly not an error in gawk.

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                                                          -
- Department of Mathematics, 110 LCB    Internet e-mail: beebe@math.utah.edu  -
- 155 S 1400 E RM 233                       beebe@acm.org  beebe@computer.org -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------



reply via email to

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