GNU bug report logs - #66256
sorting NAN values with "general-numeric’

Previous Next

Package: coreutils;

Reported by: Jorge Stolfi <stolfi <at> ic.unicamp.br>

Date: Thu, 28 Sep 2023 11:16:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Jorge Stolfi <stolfi <at> ic.unicamp.br>
To: 66256 <at> debbugs.gnu.org
Subject: bug#66256: sorting NAN values with "general-numeric’
Date: Thu, 28 Sep 2023 07:43:52 -0300
The full documentation of the "--general-numeric-sort" option of  
{sort} says that NaN values are sorted "in a consistent but  
machine-dependent order".

This is not good. The point of the IEEE floating-point standard was to  
make the results of floating-point computations be independent of the  
platform or implementation.

Please consider extending that goal to the handling of NaNs by {sort}.  
 That it, all flavors of NaN (determined by their char tails, as  
parsed by {strtod}) should be treated as equal.

The fact that different flavors of NaN have distinct binary  
representation is not an excuse to sort them as distinct, since the  
same is true of +0 and -0, which "general-numeric" sort already treats  
as equal.

As a separate suggestion, please consider having {sort} abort with an  
error message if any field that is supposed to be sorted with  
"general-numeric" is not a valid {double} value, or has some leftover  
chars that are not parsed by {strtod}.

Whether these solutions are accepted or not, please change the manpage  
explanation of "-g"/"--general-numeric-sort" to say, at least, "the  
field is parsed as a double-precision (64-bit) floating-point number  
and sorted by its numeric value".

Thanks, and all the best,

--jorge
-- 
Jorge Stolfi - Professor Titular/Full Professor
Instituto de Computação/Computer Science Dept
Universidade Estadual de Campinas/State University of Campinas
Campinas, SP - Brazil





This bug report was last modified 1 year and 266 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.