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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: Jorge Stolfi <stolfi@HIDDEN>; dated Thu, 28 Sep 2023 11:16:02 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 28 Sep 2023 11:15:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 28 07:15:35 2023
Received: from localhost ([127.0.0.1]:53149 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qlozV-0006jY-PX
	for submit <at> debbugs.gnu.org; Thu, 28 Sep 2023 07:15:35 -0400
Received: from lists.gnu.org ([2001:470:142::17]:50292)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stolfi@HIDDEN>) id 1qloVL-0005lT-EG
 for submit <at> debbugs.gnu.org; Thu, 28 Sep 2023 06:44:24 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <stolfi@HIDDEN>)
 id 1qloV1-0003f6-Dv
 for bug-coreutils@HIDDEN; Thu, 28 Sep 2023 06:44:03 -0400
Received: from taquaral.ic.unicamp.br ([143.106.7.43])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <stolfi@HIDDEN>)
 id 1qloUw-0003tA-IN
 for bug-coreutils@HIDDEN; Thu, 28 Sep 2023 06:44:00 -0400
Received: from guanabara.ic.unicamp.br (guanabara.ic.unicamp.br [143.106.7.44])
 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits))
 (No client certificate requested) (Authenticated sender: stolfi)
 by taquaral.ic.unicamp.br (Postfix) with ESMTPSA id 9E87A27C4E4A
 for <bug-coreutils@HIDDEN>; Thu, 28 Sep 2023 07:43:53 -0300 (-03)
DKIM-Filter: OpenDKIM Filter v2.11.0 taquaral.ic.unicamp.br 9E87A27C4E4A
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ic.unicamp.br;
 s=default; t=1695897833;
 bh=8tB3IgBNc8GjiSeuBXdJUFpq0xsMsz1hbEihAxExAe0=;
 h=Date:From:To:Subject:From;
 b=L4tajBwFnT4gLcOfZht9B43gEUrUChFevaf/1Y+a43a6DJpL7x6yA5T1gNFy57FKN
 X3PFc2YE/XiWnf/PofrOnpmgsRLytu8Ukvv/+UIDaVibGnOEk4KdhiQgRDgKfRlgGk
 aJ0wxfPFUwCx+VF/KqWZJH5pyTlpISAIlAHSNl94=
Received: from 187-35-195-161.dsl.telesp.net.br
 (187-35-195-161.dsl.telesp.net.br [187.35.195.161]) by
 webmail2.ic.unicamp.br (Horde Framework) with HTTPS; Thu, 28 Sep 2023
 07:43:52 -0300
Date: Thu, 28 Sep 2023 07:43:52 -0300
Message-ID: <20230928074352.Horde.e6lnpeLVHKt8TsI8KnyEFB1@HIDDEN>
From: Jorge Stolfi <stolfi@HIDDEN>
To: bug-coreutils@HIDDEN
Subject: sorting NAN values with =?utf-8?b?ImdlbmVyYWwtbnVtZXJpY+KAmQ==?=
User-Agent: Horde Application Framework 5
Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes
MIME-Version: 1.0
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=143.106.7.43; envelope-from=stolfi@HIDDEN;
 helo=taquaral.ic.unicamp.br
X-Spam_score_int: -19
X-Spam_score: -2.0
X-Spam_bar: --
X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 28 Sep 2023 07:15:28 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)


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





Acknowledgement sent to Jorge Stolfi <stolfi@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#66256; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 28 Sep 2023 11:30:02 UTC

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