GNU bug report logs - #54785
for floating point, printf should use double like in C instead of long double

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: Vincent Lefevre <vincent@HIDDEN>; dated Fri, 8 Apr 2022 09:18:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.

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


Received: (at 54785) by debbugs.gnu.org; 27 Apr 2022 18:52:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 27 14:52:33 2022
Received: from localhost ([127.0.0.1]:44433 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1njmm9-0005TH-MO
	for submit <at> debbugs.gnu.org; Wed, 27 Apr 2022 14:52:33 -0400
Received: from mail-out.m-online.net ([212.18.0.10]:42379)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <whitebox@HIDDEN>) id 1njmm7-0005T8-Tr
 for 54785 <at> debbugs.gnu.org; Wed, 27 Apr 2022 14:52:32 -0400
Received: from frontend01.mail.m-online.net (unknown [192.168.8.182])
 by mail-out.m-online.net (Postfix) with ESMTP id 4KpSY90Q1Gz1s7tB;
 Wed, 27 Apr 2022 20:52:28 +0200 (CEST)
Received: from localhost (dynscan1.mnet-online.de [192.168.6.70])
 by mail.m-online.net (Postfix) with ESMTP id 4KpSY812GCz1qqkD;
 Wed, 27 Apr 2022 20:52:28 +0200 (CEST)
X-Virus-Scanned: amavisd-new at mnet-online.de
Received: from mail.mnet-online.de ([192.168.8.182])
 by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new,
 port 10024)
 with ESMTP id p96UvnUMPR0l; Wed, 27 Apr 2022 20:52:27 +0200 (CEST)
X-Auth-Info: rbVPnGsM0kZ5sreBwTv65PfWjSq1tZgpjGRWBJNsWq9wOJoF24fF6/nw64nBZynK
Received: from igel.home (ppp-46-244-190-4.dynamic.mnet-online.de
 [46.244.190.4])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.mnet-online.de (Postfix) with ESMTPSA;
 Wed, 27 Apr 2022 20:52:27 +0200 (CEST)
Received: by igel.home (Postfix, from userid 1000)
 id A2BA42C371F; Wed, 27 Apr 2022 20:52:26 +0200 (CEST)
From: Andreas Schwab <schwab@HIDDEN>
To: Paul Eggert <eggert@HIDDEN>
Subject: Re: bug#54785: for floating point, printf should use double like in
 C instead of long double
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
 <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
 <dc8f3d13-7d8a-24ff-8a67-7ab9604a9ba8@HIDDEN>
 <7ae2a577-7a8d-b70f-e023-0d0085f20776@HIDDEN>
 <54cfdfd5-bed7-c43f-f679-653bca79420e@HIDDEN>
 <d4936cfd-5c13-42ee-8a94-cb56715c62a5@HIDDEN>
 <58c50895-153f-3c30-0e08-e31ad6173ef1@HIDDEN>
 <3e4418f6-1ee8-44cf-bf11-fa555156ae94@HIDDEN>
 <89b811d1-8956-e4d4-14d6-3c096c5e5728@HIDDEN>
X-Yow: I have seen these EGG EXTENDERS in my Supermarket..
 ..  I have read the INSTRUCTIONS...
Date: Wed, 27 Apr 2022 20:52:26 +0200
In-Reply-To: <89b811d1-8956-e4d4-14d6-3c096c5e5728@HIDDEN> (Paul Eggert's
 message of "Wed, 27 Apr 2022 10:25:23 -0700")
Message-ID: <87ilqu5pg5.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.5 (/)
X-Debbugs-Envelope-To: 54785
Cc: Glenn Golden <gdg@HIDDEN>, 54785 <at> debbugs.gnu.org
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: -1.5 (-)

On Apr 27 2022, Paul Eggert wrote:

> Any proposal to change 'long double' to always output leading 0 or 1 needs
> to deal with the fact that this'd lengthen the output string.

The real reason for not using that format is that 64 bits can be
conveniently formatted without having to shift around the mantissa, and
having to handle the shifted out bits specially.  For IEEE quad with its
112 bits of mantissa and the hidden bit, this format is again more
convenient.

-- 
Andreas Schwab, schwab@HIDDEN
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at 54785) by debbugs.gnu.org; 27 Apr 2022 17:25:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 27 13:25:32 2022
Received: from localhost ([127.0.0.1]:44251 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1njlPw-0006u9-Hb
	for submit <at> debbugs.gnu.org; Wed, 27 Apr 2022 13:25:32 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:42174)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1njlPu-0006to-7a
 for 54785 <at> debbugs.gnu.org; Wed, 27 Apr 2022 13:25:31 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id D00991600A7;
 Wed, 27 Apr 2022 10:25:24 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id CHLU1XstTiAK; Wed, 27 Apr 2022 10:25:24 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 24AC11600ED;
 Wed, 27 Apr 2022 10:25:24 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id osKb1j_xAXMX; Wed, 27 Apr 2022 10:25:24 -0700 (PDT)
Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E413D1600A7;
 Wed, 27 Apr 2022 10:25:23 -0700 (PDT)
Message-ID: <89b811d1-8956-e4d4-14d6-3c096c5e5728@HIDDEN>
Date: Wed, 27 Apr 2022 10:25:23 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.8.0
Subject: Re: bug#54785: for floating point, printf should use double like in C
 instead of long double
Content-Language: en-US
To: Glenn Golden <gdg@HIDDEN>
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
 <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
 <dc8f3d13-7d8a-24ff-8a67-7ab9604a9ba8@HIDDEN>
 <7ae2a577-7a8d-b70f-e023-0d0085f20776@HIDDEN>
 <54cfdfd5-bed7-c43f-f679-653bca79420e@HIDDEN>
 <d4936cfd-5c13-42ee-8a94-cb56715c62a5@HIDDEN>
 <58c50895-153f-3c30-0e08-e31ad6173ef1@HIDDEN>
 <3e4418f6-1ee8-44cf-bf11-fa555156ae94@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
In-Reply-To: <3e4418f6-1ee8-44cf-bf11-fa555156ae94@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 54785
Cc: 54785 <at> debbugs.gnu.org
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: -3.3 (---)

On 4/27/22 05:10, Glenn Golden wrote:
> Ok, I see what you mean, thanks for the explanation. I'll pose the question (or maybe file a bug report) on the glibc list.

By the way I now think I see a reason for why glibc does things the way 
it does: it minimizes output size.

'double' has 53 bits counting the hidden bit, and with 53/4 you have 13 
hex digits plus one leading digit that is either 0 (unnormalized) or 1 
(normalized).

'long double' has 64 bits and with 64/4 you have 16 hex digits, where 
the leading digit is 0-7 (unnormalized), 8-f (normalized).

Any proposal to change 'long double' to always output leading 0 or 1 
needs to deal with the fact that this'd lengthen the output string.




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at 54785) by debbugs.gnu.org; 27 Apr 2022 12:11:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Apr 27 08:11:03 2022
Received: from localhost ([127.0.0.1]:41450 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1njgVb-0003AR-Gr
	for submit <at> debbugs.gnu.org; Wed, 27 Apr 2022 08:11:03 -0400
Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:45043)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gdg@HIDDEN>) id 1njgVV-00039l-3M
 for 54785 <at> debbugs.gnu.org; Wed, 27 Apr 2022 08:11:01 -0400
Received: from compute5.internal (compute5.nyi.internal [10.202.2.45])
 by mailout.west.internal (Postfix) with ESMTP id F18F832007F9;
 Wed, 27 Apr 2022 08:10:50 -0400 (EDT)
Received: from imap47 ([10.202.2.97])
 by compute5.internal (MEProxy); Wed, 27 Apr 2022 08:10:51 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zplane.com; h=cc
 :content-type:date:date:from:from:in-reply-to:in-reply-to
 :message-id:mime-version:references:reply-to:sender:subject
 :subject:to:to; s=fm3; t=1651061450; x=1651147850; bh=FScGCdtGNL
 RCbb7Fc9O1OA/hWHLT5BIlKY/NN3Ajoj4=; b=ZJwPR6SckF8LnpohaH7FM9MwIx
 Iqa7U59+U0dcN0crtz7ZvVCNnDMAp7mI9EmdAHK3+rmUEVYqyDZiTg3Mf0LhXZMY
 SCvUPaCDQyaLi9XRDyX4rwSpO8rn1mg8X/HhEMzpXrDVEESwbipfe2yikz8JbQR7
 4H6bi6ZVDw6q38R/aMmEdWVetVCUUJvU6xmBfdQN1XleVY6pqT4El8oPdJU4BZPQ
 SyUaBBiSAQDlXO80Dctzb50bK5Kzz93gQiMDFBuUlFUsSxh9ePYwfDkKWvC7uPO9
 uj3WnPkCona7efGyTHLDbI3KTuznBx5T42/CnBPVj82+2Zba8aV8mx5kKSVw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-type:date:date:from:from
 :in-reply-to:in-reply-to:message-id:mime-version:references
 :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651061450; x=
 1651147850; bh=FScGCdtGNLRCbb7Fc9O1OA/hWHLT5BIlKY/NN3Ajoj4=; b=t
 wcZn2CD3y49JE0K3hST9nGJzKGSRtypmbfzWaRYy5O3/vTWxzQSC0cWM9u/1xBgz
 Ir7rqYfNO+wpoLk6lkF6T0PUqeJjee/SX2YfNwY6XMUuvrqHbVzvqq2UBXBOefyP
 UJH0AgxgqLeZRCshWP8++C37qWG4+ZogLslXwJtShQGTa8aCrAhoy9L0FcwOk+Qk
 aYlEek4Ftbc4Gup11CFAT0AlVzt3+sfH1c1HCdn7QQZIxq7bXSYxyFIZjUlJfWsa
 RysWRAtgORndQViysoXqsuZC26Zv8a2KMZfb6PMKZiLiqcEYlEyA1HmLtQGaDF4P
 A215QAE+c+uCtppBfKWqA==
X-ME-Sender: <xms:yjJpYsTNJZFnLZmYPNfIHCkme_Plub-bCD13DC07e74zbwTCU_nZqw>
 <xme:yjJpYpzQnLSWIwmRqIKR4k9p_hyNx__mFBPBFjfMIn1VTUQ0_AtbzePq_EWw2qgEd
 AxAsTh7MZBPNnYO>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehgdeghecutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc
 fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfifhlvghn
 nhcuifholhguvghnfdcuoehgughgseiiphhlrghnvgdrtghomheqnecuggftrfgrthhtvg
 hrnhepueeuueeffefhteegtdejtdffheejteevtdehhedvheethfeftdehffdtueejleet
 necuffhomhgrihhnpehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrg
 hrrghmpehmrghilhhfrhhomhepghgughesiihplhgrnhgvrdgtohhm
X-ME-Proxy: <xmx:yjJpYp1SYVmu6KI08u5fK7TxDshk2lmeYE2Oj6q6wfq6ERpSuu2HLQ>
 <xmx:yjJpYgCnSBIXY48ORTl4shdvh0G3zzCkN00bPM3Vf7p0ZQg4NBo3Mw>
 <xmx:yjJpYljfPD99TD7Iu_o0jyQzan6Dgq235Ur8zBCRFny2wwHuM6fzsw>
 <xmx:yjJpYvf6Fyjve84_wpVl-1_xEQTIYHUKE9zDatba3v-8y7iCl-bxYw>
Received: by mailuser.nyi.internal (Postfix, from userid 501)
 id 14CEA2740386; Wed, 27 Apr 2022 08:10:50 -0400 (EDT)
X-Mailer: MessagingEngine.com Webmail Interface
User-Agent: Cyrus-JMAP/3.7.0-alpha0-569-g7622ad95cc-fm-20220421.002-g7622ad95
Mime-Version: 1.0
Message-Id: <3e4418f6-1ee8-44cf-bf11-fa555156ae94@HIDDEN>
In-Reply-To: <58c50895-153f-3c30-0e08-e31ad6173ef1@HIDDEN>
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
 <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
 <dc8f3d13-7d8a-24ff-8a67-7ab9604a9ba8@HIDDEN>
 <7ae2a577-7a8d-b70f-e023-0d0085f20776@HIDDEN>
 <54cfdfd5-bed7-c43f-f679-653bca79420e@HIDDEN>
 <d4936cfd-5c13-42ee-8a94-cb56715c62a5@HIDDEN>
 <58c50895-153f-3c30-0e08-e31ad6173ef1@HIDDEN>
Date: Wed, 27 Apr 2022 06:10:21 -0600
From: "Glenn Golden" <gdg@HIDDEN>
To: "Paul Eggert" <eggert@HIDDEN>, 54785 <at> debbugs.gnu.org
Subject: Re: bug#54785: for floating point,
 printf should use double like in C instead of long double
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 54785
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: -1.7 (-)



On Mon, Apr 25, 2022, at 19:33, Paul Eggert wrote:
> On 4/25/22 16:50, Glenn Golden wrote:
>> 
>> 
>> On Mon, Apr 25, 2022, at 13:06, Paul Eggert wrote:
>>>
>>> I'd like coreutils printf to stay compatible with Bash printf. Thanks.
>>>
>> 
>> Is there any interest/motivation for consistentizing {coreutils printf, bash printf} with glibc printf? There's a minor but notable inconsistency between them for %a format. See
>> 
>>      https://lists.gnu.org/archive/html/coreutils/2022-04/msg00020.html
>> 
>> I asked about this on the coreutils list, but no response.
>
> To some extent it's the same problem. If Bash and coreutils printf 
> change to use 'double', they'll output the same thing that C printf outputs.
>
> But to some extent it's a different problem, as the Bash and coreutils 
> printf use glibc printf with long double, and the latter isn't working 
> consistently with double. I suppose filing a glibc bug report might 
> address this different problem.
>

Ok, I see what you mean, thanks for the explanation. I'll pose the question (or maybe file a bug report) on the glibc list.

Thanks,
Glenn




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at 54785) by debbugs.gnu.org; 26 Apr 2022 01:33:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 25 21:33:38 2022
Received: from localhost ([127.0.0.1]:36457 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1njA5C-0006r7-67
	for submit <at> debbugs.gnu.org; Mon, 25 Apr 2022 21:33:38 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33698)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1njA5A-0006qs-H0
 for 54785 <at> debbugs.gnu.org; Mon, 25 Apr 2022 21:33:36 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id EDC671600EF;
 Mon, 25 Apr 2022 18:33:30 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id 5OUkT87s-RP2; Mon, 25 Apr 2022 18:33:30 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0C1211600F6;
 Mon, 25 Apr 2022 18:33:30 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id d-3RHKuDocxD; Mon, 25 Apr 2022 18:33:29 -0700 (PDT)
Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id DC5A31600EF;
 Mon, 25 Apr 2022 18:33:29 -0700 (PDT)
Message-ID: <58c50895-153f-3c30-0e08-e31ad6173ef1@HIDDEN>
Date: Mon, 25 Apr 2022 18:33:29 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.8.0
Subject: Re: bug#54785: for floating point, printf should use double like in C
 instead of long double
Content-Language: en-US
To: Glenn Golden <gdg@HIDDEN>, 54785 <at> debbugs.gnu.org
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
 <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
 <dc8f3d13-7d8a-24ff-8a67-7ab9604a9ba8@HIDDEN>
 <7ae2a577-7a8d-b70f-e023-0d0085f20776@HIDDEN>
 <54cfdfd5-bed7-c43f-f679-653bca79420e@HIDDEN>
 <d4936cfd-5c13-42ee-8a94-cb56715c62a5@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
In-Reply-To: <d4936cfd-5c13-42ee-8a94-cb56715c62a5@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 54785
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: -3.3 (---)

On 4/25/22 16:50, Glenn Golden wrote:
> 
> 
> On Mon, Apr 25, 2022, at 13:06, Paul Eggert wrote:
>>
>> I'd like coreutils printf to stay compatible with Bash printf. Thanks.
>>
> 
> Is there any interest/motivation for consistentizing {coreutils printf, bash printf} with glibc printf? There's a minor but notable inconsistency between them for %a format. See
> 
>      https://lists.gnu.org/archive/html/coreutils/2022-04/msg00020.html
> 
> I asked about this on the coreutils list, but no response.

To some extent it's the same problem. If Bash and coreutils printf 
change to use 'double', they'll output the same thing that C printf outputs.

But to some extent it's a different problem, as the Bash and coreutils 
printf use glibc printf with long double, and the latter isn't working 
consistently with double. I suppose filing a glibc bug report might 
address this different problem.




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 25 Apr 2022 23:51:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 25 19:51:23 2022
Received: from localhost ([127.0.0.1]:36336 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nj8UE-0004Ba-Tb
	for submit <at> debbugs.gnu.org; Mon, 25 Apr 2022 19:51:23 -0400
Received: from lists.gnu.org ([209.51.188.17]:56572)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gdg@HIDDEN>) id 1nj8UD-0004BT-50
 for submit <at> debbugs.gnu.org; Mon, 25 Apr 2022 19:51:21 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:45474)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <gdg@HIDDEN>) id 1nj8UC-0003xy-Sc
 for bug-coreutils@HIDDEN; Mon, 25 Apr 2022 19:51:20 -0400
Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:37747)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <gdg@HIDDEN>) id 1nj8UA-0001Eu-Ts
 for bug-coreutils@HIDDEN; Mon, 25 Apr 2022 19:51:20 -0400
Received: from compute5.internal (compute5.nyi.internal [10.202.2.45])
 by mailout.west.internal (Postfix) with ESMTP id 29C753202100
 for <bug-coreutils@HIDDEN>; Mon, 25 Apr 2022 19:51:15 -0400 (EDT)
Received: from imap47 ([10.202.2.97])
 by compute5.internal (MEProxy); Mon, 25 Apr 2022 19:51:15 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zplane.com; h=cc
 :content-type:date:date:from:from:in-reply-to:in-reply-to
 :message-id:mime-version:references:reply-to:sender:subject
 :subject:to:to; s=fm3; t=1650930674; x=1651017074; bh=RrIPTV2fWg
 1F8GNeCiElngr+brNDIqVcQu99kJE84og=; b=I97toRrddFJXOeLRDyRG3FNGv1
 c7ryzFPrS2sxJK3kLfyHhs8VwAmQm9J/H1Hc+JvaJQYKFbEIYldQcBrutDS/HK6j
 UP6oSUHxBcguKaeaOJLU0h5tkE6eWOFx8XbDwf0nLFPficDn5nTxKNj8WNi3xtwf
 SrnpLaTCD9cNGXFx4yaTfbXZK5tvkYg3F8VBOUGrpPuRYZOY6zzNzeubmcqAnLlN
 QhqyxZ2kUP3pM2kKm8jFsBrKOsSLaXVr4qyfxDRhmtsEkGNnYYunI0XtVga02Jvb
 qrt+chvAaCs5TaZxEIEMxsBA/4L8isZzd8GDFSwk8xKatZiUibiWsKjv/e6A==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-type:date:date:from:from
 :in-reply-to:in-reply-to:message-id:mime-version:references
 :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1650930674; x=
 1651017074; bh=RrIPTV2fWg1F8GNeCiElngr+brNDIqVcQu99kJE84og=; b=p
 lNY0r5hVExDSsnon2XMQU4voTBn/g6GmMliivUM6OdMUa+4eo0Rfa1MZfytccepB
 /FX9Z31kxmNrOfIadlKv4vfj0jDNzN+EdE0tDpYUUCke5Aqw86xF+l0lGqwsuAEK
 dv0HAEM55ihY0SzHfyskb/mOLv/BSZQ+L1oHg54gomf30nqIXTBe5BLe3/KDx02z
 rS7BHviYAXE7cvh1kzEqc7AApbuFtVUCscE5jUbuo+syO3lr8aG7dJA5dZD+P35U
 ZiPfqvCzsH52ndEThg+PrSVQ97+pb2yrExU1HUvyK6Gm7nR+pxMJT4O8xCxucgnI
 10S5GWjmVos2xrQImb9fg==
X-ME-Sender: <xms:8jNnYpw4sz82zFTo3wBQJu0zDr11l2roXhSENu0cFPpLxO3Hl8Q4Qw>
 <xme:8jNnYpRe8eM8_Vt_I4EwsgTNyutiFNt_ZIbvmO_oBGaIvCMC5cAjAo_N8rtsrH5jK
 FS3abFaPBOW7cY5>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddvgddviecutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesthdtre
 dtreertdenucfhrhhomhepfdfilhgvnhhnucfiohhluggvnhdfuceoghgughesiihplhgr
 nhgvrdgtohhmqeenucggtffrrghtthgvrhhnpeeuueeufeefhfetgedtjedtffehjeetve
 dtheehvdehtefhfedthefftdeujeelteenucffohhmrghinhepghhnuhdrohhrghenucev
 lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgughgseiiph
 hlrghnvgdrtghomh
X-ME-Proxy: <xmx:8jNnYjWVjmi9YRckFZrk6KYNrrkNYxec7b_B3h_tKDTuFp1d_w96DQ>
 <xmx:8jNnYriRgmbL6CiIhIF1MQm8_B38aHc6mOZtn4qoLBlOpIYFeFRGeQ>
 <xmx:8jNnYrAfZxYB0pS0zi_g-9Wkru3Nq6szBUMMQ6YDMSLzmrH7QTHaSw>
 <xmx:8jNnYuOaHyWaO4OLhNxND-lL1qPD_AMDlMVcjKymFzg9bDP03w0jZg>
Received: by mailuser.nyi.internal (Postfix, from userid 501)
 id 671E62740419; Mon, 25 Apr 2022 19:51:14 -0400 (EDT)
X-Mailer: MessagingEngine.com Webmail Interface
User-Agent: Cyrus-JMAP/3.7.0-alpha0-569-g7622ad95cc-fm-20220421.002-g7622ad95
Mime-Version: 1.0
Message-Id: <d4936cfd-5c13-42ee-8a94-cb56715c62a5@HIDDEN>
In-Reply-To: <54cfdfd5-bed7-c43f-f679-653bca79420e@HIDDEN>
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
 <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
 <dc8f3d13-7d8a-24ff-8a67-7ab9604a9ba8@HIDDEN>
 <7ae2a577-7a8d-b70f-e023-0d0085f20776@HIDDEN>
 <54cfdfd5-bed7-c43f-f679-653bca79420e@HIDDEN>
Date: Mon, 25 Apr 2022 17:50:54 -0600
From: "Glenn Golden" <gdg@HIDDEN>
To: bug-coreutils@HIDDEN
Subject: Re: bug#54785: for floating point,
 printf should use double like in C instead of long double
Content-Type: text/plain
Received-SPF: pass client-ip=64.147.123.24; envelope-from=gdg@HIDDEN;
 helo=wout1-smtp.messagingengine.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.7 (-)
X-Debbugs-Envelope-To: submit
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: -2.7 (--)



On Mon, Apr 25, 2022, at 13:06, Paul Eggert wrote:
>
> I'd like coreutils printf to stay compatible with Bash printf. Thanks.
>

Is there any interest/motivation for consistentizing {coreutils printf, bash printf} with glibc printf? There's a minor but notable inconsistency between them for %a format. See

    https://lists.gnu.org/archive/html/coreutils/2022-04/msg00020.html

I asked about this on the coreutils list, but no response.

Thanks,
Glenn




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at 54785) by debbugs.gnu.org; 25 Apr 2022 19:06:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 25 15:06:47 2022
Received: from localhost ([127.0.0.1]:36108 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nj42p-0003VG-MY
	for submit <at> debbugs.gnu.org; Mon, 25 Apr 2022 15:06:47 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:35348)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1nj42n-0003V3-Ku
 for 54785 <at> debbugs.gnu.org; Mon, 25 Apr 2022 15:06:45 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id A39E51600DB;
 Mon, 25 Apr 2022 12:06:39 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id MMNABUac2niR; Mon, 25 Apr 2022 12:06:39 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 03C901600EB;
 Mon, 25 Apr 2022 12:06:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id jN2B-T0zBIpt; Mon, 25 Apr 2022 12:06:38 -0700 (PDT)
Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id D6C7B1600DB;
 Mon, 25 Apr 2022 12:06:38 -0700 (PDT)
Message-ID: <54cfdfd5-bed7-c43f-f679-653bca79420e@HIDDEN>
Date: Mon, 25 Apr 2022 12:06:31 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.8.0
Subject: Re: bug#54785: for floating point, printf should use double like in C
 instead of long double
Content-Language: en-US
To: chet.ramey@HIDDEN
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
 <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
 <dc8f3d13-7d8a-24ff-8a67-7ab9604a9ba8@HIDDEN>
 <7ae2a577-7a8d-b70f-e023-0d0085f20776@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
In-Reply-To: <7ae2a577-7a8d-b70f-e023-0d0085f20776@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 54785
Cc: vincent@HIDDEN, 54785 <at> debbugs.gnu.org, bug-bash@HIDDEN
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: -3.3 (---)

On 4/25/22 11:22, Chet Ramey wrote:
> Thanks for the input.

You're welcome. Whenever you decide what to do about this, could you 
please let us know? I'd like coreutils printf to stay compatible with 
Bash printf. Thanks.




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 25 Apr 2022 18:22:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 25 14:22:44 2022
Received: from localhost ([127.0.0.1]:36045 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nj3MB-0002PE-NN
	for submit <at> debbugs.gnu.org; Mon, 25 Apr 2022 14:22:43 -0400
Received: from lists.gnu.org ([209.51.188.17]:39018)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <chet.ramey@HIDDEN>) id 1nj3M5-0002P1-EK
 for submit <at> debbugs.gnu.org; Mon, 25 Apr 2022 14:22:42 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:38770)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <chet.ramey@HIDDEN>)
 id 1nj3M4-0007Oc-9B
 for bug-coreutils@HIDDEN; Mon, 25 Apr 2022 14:22:37 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:17070
 helo=mpv1-2015.case.edu)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <chet.ramey@HIDDEN>)
 id 1nj3Ly-0001Bm-VA
 for bug-coreutils@HIDDEN; Mon, 25 Apr 2022 14:22:33 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu;
 s=smtp-primary; t=1650910951;
 bh=zzD5uVOubQ9/E61jhPUpabualM1sH0DD3AKEiI4r/OI=;
 h=Message-ID:Date:MIME-Version:Reply-To:Cc:Subject:To:References:
 From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
 b=JNX72nXLJHq5dnH5QdL3gSJYJ4qhdIl/MtNS8q6C9yGpdKIu2gDJltqazu3EYwOQK7
 U/PHn63VMXtr2ty2KaVcUqEugplW51tTpAtk3wkcUaBzlmaXetysb/KqSQZ6DiSMPjD
 EWo8T/LypAN89eId8YRddml7xqeEg9f76v0WlXOdZQAeKxuB2Dz0U6HAI57KW+S4EIr
 2tz86Nvj4BRoaGCjExwndV6UUu1ONnRfezRUsU85i3+3aodXoBfWn+GgoEcz/mBGCf9
 GJGBJQIERQ3sJQzOaHg3bSfV4hauTfH6oOBrzzAOJBX5pqeCysDfIJtmu0Dei3qWr3b
 3lat07Ag==
Received: from mpv6-2015.CWRU.Edu (EHLO mpv6-2015.case.edu) ([129.22.103.202])
 by mpv1-2015.case.edu (MOS 4.4.8-GA FastPath queued)
 with ESMTP id CIA37641; Mon, 25 Apr 2022 14:22:29 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu;
 s=smtp-primary; t=1650910949;
 bh=zzD5uVOubQ9/E61jhPUpabualM1sH0DD3AKEiI4r/OI=;
 h=Message-ID:Date:MIME-Version:Reply-To:Cc:Subject:To:References:
 From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
 b=a8eUWRwga4OQCX2Yxxh88/1z7wL8+t0dU+dv3HNYVwiQyPvDNqivpFRQ1vg7lle0HS
 7S6ZklimJ2hNClkeOtlXeq3GxqyS1g3rK7QU10+8pK7jFi0GNLWvrTm8AFBhTJq68+h
 8YDxLrNbq3+n8sdHNwKb6ks2md1XD6frUpetmbq6g4UtrNOvasAP7+/MkciAlg8wIio
 C1orE9e0wG1V0BT3DFHUMoacFlgeli6IQwHV1hYeGIzOrhydxCFCdSQkpnuP4GVPK3J
 9qXipYQQn7kiHJgdNqXMcZ7xGivq0MA1nQlS0OFKxeyVT69KKvjUx1UxKGeQ1KV5/v5
 U2dtBgoA==
Received: from mail-qt1-f199.google.com (EHLO mail-qt1-f199.google.com)
 ([209.85.160.199])
 by mpv6-2015.case.edu (MOS 4.4.8-GA FastPath queued)
 with ESMTP id HZB81158; Mon, 25 Apr 2022 14:22:28 -0400 (EDT)
Received: by mail-qt1-f199.google.com with SMTP id
 cj27-20020a05622a259b00b002f334b76068so8464182qtb.4
 for <bug-coreutils@HIDDEN>; Mon, 25 Apr 2022 11:22:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=g-case;
 h=message-id:date:mime-version:user-agent:reply-to:cc:subject
 :content-language:to:references:from:organization:in-reply-to
 :content-transfer-encoding;
 bh=3vridhOoiOfUHm6ddU0eIBPJisdjhkGJ4gI/7igfSFE=;
 b=Jza1ESjtJkbD4aPIPx9qpMp9n1ZT1BMYut/cugS0F+ljXr3tSPOjvXZf1oeZL1mUZw
 h3P885RwcVNpsSfdMPT9jCu4417mLSwn+viHNgodO+lMmG1UY/Nf2QQ4cpY93TMvNUEK
 1++IhStOs4hC7VXkBE2sliCYY3c4FOcxz/JsQYP5t9dVgZYQ+mR7paw3Cb0EaXIOQaOl
 3E2fWk/p1KExN6Udw3dhpFQTibUsjmzRCwde5kq84HXcglVeGGWlwsxjMaRE/zVjG/De
 q5qv5W1OvkzXi/2HFCgD2ZdiZLCwwWpbZBF43H2v3cV4A0nOMKnQ7r06fXasU74cZHGL
 sIrA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:message-id:date:mime-version:user-agent:reply-to
 :cc:subject:content-language:to:references:from:organization
 :in-reply-to:content-transfer-encoding;
 bh=3vridhOoiOfUHm6ddU0eIBPJisdjhkGJ4gI/7igfSFE=;
 b=IXxV5+S80Wz3zaREXXI+pIqb4vUoaaGs6MUuVVpF1rfJASYSK3q92y1bOMpXGfU5Xh
 UtOt4PGkfgMuQi+bNmHY+u5K5DTWzThLDIkEfa21yDMuDrpxMPK71+rwXqGftGNBobmw
 V3DkvEjzjsWHvcwa6ti0ZrHkuteME56p9GXOdfFGQIuMFK53b3sBzdw7Q9bNjJaDs7sI
 as/z1I85mYNuCTkbbp2zgCzKzUv7BbpmlH50LAAh8RDv7IJxA8EBFUfHNp0Nl5sauH57
 G57RDuizUFVklRoa/T0ULtNNoud2UiqqC7knGWQTyClmLs74SE/z+0Ta6Ned/B+mIL7J
 Y6tQ==
X-Gm-Message-State: AOAM532ibtcsg9moBEd3JMMWVTmnzTe8KusRk4DtLW3UxukZrsvX/JyZ
 TDhfRl3xF4JlGphugl7ivU9djzTNzlgH1dn9YU+4TyJXQpESc09AKKHTh86JJF06T44fPpq0K/9
 iMxQJdN1y38wkor59EQ==
X-Received: by 2002:a05:620a:1aa9:b0:69e:e20e:7961 with SMTP id
 bl41-20020a05620a1aa900b0069ee20e7961mr10890277qkb.19.1650910948342; 
 Mon, 25 Apr 2022 11:22:28 -0700 (PDT)
X-Google-Smtp-Source: ABdhPJxksrMLlrmtSA1A7YNOxpWSZv1FoUhHohnp2EXgnZdFNTwNvZS1douSJzQ9/RP2aVSP+ff7jQ==
X-Received: by 2002:a05:620a:1aa9:b0:69e:e20e:7961 with SMTP id
 bl41-20020a05620a1aa900b0069ee20e7961mr10890263qkb.19.1650910948073; 
 Mon, 25 Apr 2022 11:22:28 -0700 (PDT)
Received: from [192.168.0.109] (cpe-107-10-247-26.neo.res.rr.com.
 [107.10.247.26]) by smtp.gmail.com with ESMTPSA id
 c20-20020a05622a059400b002e1d59e68f3sm6821374qtb.48.2022.04.25.11.22.27
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 25 Apr 2022 11:22:27 -0700 (PDT)
Message-ID: <7ae2a577-7a8d-b70f-e023-0d0085f20776@HIDDEN>
Date: Mon, 25 Apr 2022 14:22:26 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
 Gecko/20100101 Thunderbird/91.8.1
Subject: Re: bug#54785: for floating point, printf should use double like in C
 instead of long double
Content-Language: en-US
To: Paul Eggert <eggert@HIDDEN>
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
 <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
 <dc8f3d13-7d8a-24ff-8a67-7ab9604a9ba8@HIDDEN>
From: Chet Ramey <chet.ramey@HIDDEN>
Organization: ITS, Case Western Reserve University
In-Reply-To: <dc8f3d13-7d8a-24ff-8a67-7ab9604a9ba8@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Mirapoint-IP-Reputation: reputation=Good-1, source=Queried,
 refid=tid=0001.0A742F8E.6266DC21.0033, actions=tag
X-Mirapoint-Virus-RAPID-Raw: score=unknown(0),
 refid=str=0001.0A742F1B.6266E6E5.001C, ss=1, re=0.000, recu=0.000, reip=0.000,
 cl=1, cld=1, fgs=0, ip=0.0.0.0,
 so=2016-11-06 16:00:04, dmn=2013-03-21 17:37:32
X-Mirapoint-Loop-Id: 21ad178f6929a81a43d9cb1af0ad68c3
X-Mirapoint-IP-Reputation: reputation=good-1, source=Fixed, refid=n/a,
 actions=tag
X-Junkmail-Status: score=8/90, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/90, refid=2.7.2:2022.4.25.174525:17:8.317, ip=,
 rules=__YOUTUBE_RCVD, DKIM_SIGNATURE,
 __X_GOOGLE_DKIM_SIGNATURE, __X_GM_MESSAGE_STATE,
 __X_GOOGLE_SMTP_SOURCE, __HAS_MSGID, __SANE_MSGID,
 DATE_TZ_NA, __MIME_VERSION, __USER_AGENT,
 __MOZILLA_USER_AGENT, __HAS_REPLYTO, __HAS_CC_HDR,
 __MULTIPLE_RCPTS_CC_X2, __CC_NAME,
 __CC_NAME_DIFF_FROM_ACC, __SUBJ_REPLY,
 __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
 __SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME,
 __TO_NAME_DIFF_FROM_ACC, __HAS_REFERENCES, __REFERENCES,
 __HAS_FROM, FROM_EDU_TLD, __IN_REP_TO, __CT,
 __CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
 __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
 __HEADER_ORDER_FROM, __RCPT_DOMAIN_NOT_TO,
 __REPLYTO_SAMEAS_FROM_DOMAIN, __DKIM_ALIGNS_1,
 __DKIM_ALIGNS_2, __FUR_HEADER, __ANY_URI, __URI_MAILTO,
 __URI_WITH_PATH, __URI_ENDS_IN_SLASH, __URI_NO_WWW,
 __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY,
 [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
Received-SPF: pass client-ip=129.22.103.226; envelope-from=chet.ramey@HIDDEN;
 helo=mpv1-2015.case.edu
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001,
 RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: Vincent Lefevre <vincent@HIDDEN>, bug-coreutils@HIDDEN,
 bug-bash@HIDDEN, chet.ramey@HIDDEN
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>
Reply-To: chet.ramey@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

On 4/25/22 11:03 AM, Paul Eggert wrote:
> On 4/11/22 11:52, Chet Ramey wrote:
>> On 4/9/22 3:31 PM, Paul Eggert wrote:
> 
>> It sounds like there are three cases.
>>
>> 1. If the `L' modifier is supplied, as an extension (POSIX doesn't allow
>>     length modifiers for the printf utility), use long double. This would
>>     work in both default and posix modes.
>>
>> 2. In posix mode, use strtod() and double.
>>
>> 3. In default mode, use the existing code to get the highest possible
>>     precision, as the code has done for over 20 years.
> 
> That'll fix the POSIX compatibility bug. However, it may be better for Bash 
> to just do (1) if 'L' is supplied and (2) otherwise, even if this is less 
> precise than (3). Doing it this simpler way will likely be more useful for 
> the small number of people who care whether 'printf' uses 'double' or 'long 
> double' internally (and nobody else will care).

Thanks for the input.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@HIDDEN    http://tiswww.cwru.edu/~chet/




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 25 Apr 2022 15:03:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 25 11:03:28 2022
Received: from localhost ([127.0.0.1]:35799 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nj0FL-0002QZ-Uv
	for submit <at> debbugs.gnu.org; Mon, 25 Apr 2022 11:03:28 -0400
Received: from lists.gnu.org ([209.51.188.17]:37520)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1nj0FJ-0002Q2-HK
 for submit <at> debbugs.gnu.org; Mon, 25 Apr 2022 11:03:25 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:44726)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eggert@HIDDEN>)
 id 1nj0FH-0000dM-Tt; Mon, 25 Apr 2022 11:03:23 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:51588)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eggert@HIDDEN>)
 id 1nj0FF-0002DZ-Pl; Mon, 25 Apr 2022 11:03:23 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 01DEF1600D1;
 Mon, 25 Apr 2022 08:03:19 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id CIeg_kPZlSyW; Mon, 25 Apr 2022 08:03:13 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 347F91600DB;
 Mon, 25 Apr 2022 08:03:13 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id DiVsURi9txdD; Mon, 25 Apr 2022 08:03:13 -0700 (PDT)
Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com
 [172.91.119.151])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 0080B1600D4;
 Mon, 25 Apr 2022 08:03:12 -0700 (PDT)
Message-ID: <dc8f3d13-7d8a-24ff-8a67-7ab9604a9ba8@HIDDEN>
Date: Mon, 25 Apr 2022 08:03:12 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.7.0
Content-Language: en-US
To: chet.ramey@HIDDEN
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
 <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Subject: Re: bug#54785: for floating point, printf should use double like in C
 instead of long double
In-Reply-To: <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@HIDDEN;
 helo=zimbra.cs.ucla.edu
X-Spam_score_int: -41
X-Spam_score: -4.2
X-Spam_bar: ----
X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001,
 RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: Vincent Lefevre <vincent@HIDDEN>, bug-coreutils@HIDDEN,
 bug-bash@HIDDEN
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: -2.3 (--)

On 4/11/22 11:52, Chet Ramey wrote:
> On 4/9/22 3:31 PM, Paul Eggert wrote:

> It sounds like there are three cases.
>=20
> 1. If the `L' modifier is supplied, as an extension (POSIX doesn't allo=
w
>  =C2=A0=C2=A0 length modifiers for the printf utility), use long double=
. This would
>  =C2=A0=C2=A0 work in both default and posix modes.
>=20
> 2. In posix mode, use strtod() and double.
>=20
> 3. In default mode, use the existing code to get the highest possible
>  =C2=A0=C2=A0 precision, as the code has done for over 20 years.

That'll fix the POSIX compatibility bug. However, it may be better for=20
Bash to just do (1) if 'L' is supplied and (2) otherwise, even if this=20
is less precise than (3). Doing it this simpler way will likely be more=20
useful for the small number of people who care whether 'printf' uses=20
'double' or 'long double' internally (and nobody else will care).

Doing it this way is what BSD sh does, and it's good to be compatible=20
with BSD sh. Similarly for dash and for other shells.

It's also what other GNU programs do. For example, on x86-64:

   $ awk 'BEGIN {printf "%.100g\n", 0.1}'
   0.1000000000000000055511151231257827021181583404541015625
   $ emacs -batch -eval '(message "%.100g" 0.1)'
   0.1000000000000000055511151231257827021181583404541015625
   $ printf "%.100g\n" 0.1
   0.1000000000000000000013552527156068805425093160010874271392822265625

printf is the outlier here, and although its answer is closer to the=20
mathematical value, that's not as useful as being closer to what most=20
other apps do.

Perhaps it was OK for sh printf to use long double 20 years ago. I even=20
had a hand in implementing that.[1] But nowadays it feels like a=20
misfire. The overwhelming majority of apps that have developed over the=20
past 20 years that use newer languages like JavaScript and Java, do not=20
support 'long double'; when interoperating with these apps, using 'long=20
double' in Bash printf likely causes more trouble than it cures.

[1]:=20
https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=3D830de2708207=
b7e48464e4778b55e582bac49832




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 12 Apr 2022 00:27:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 11 20:27:53 2022
Received: from localhost ([127.0.0.1]:46489 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ne4Ns-0001rn-W4
	for submit <at> debbugs.gnu.org; Mon, 11 Apr 2022 20:27:53 -0400
Received: from lists.gnu.org ([209.51.188.17]:58864)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vincent@HIDDEN>) id 1ne4Nr-0001rg-ON
 for submit <at> debbugs.gnu.org; Mon, 11 Apr 2022 20:27:52 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:57476)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vincent@HIDDEN>)
 id 1ne4Nr-0000lE-Ee; Mon, 11 Apr 2022 20:27:51 -0400
Received: from joooj.vinc17.net ([155.133.131.76]:38516)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vincent@HIDDEN>)
 id 1ne4Np-00012Z-UN; Mon, 11 Apr 2022 20:27:51 -0400
Received: from smtp-zira.vinc17.net (128.119.75.86.rev.sfr.net [86.75.119.128])
 by joooj.vinc17.net (Postfix) with ESMTPSA id 96D9523D;
 Tue, 12 Apr 2022 02:27:38 +0200 (CEST)
Received: by zira.vinc17.org (Postfix, from userid 1000)
 id B95402800320; Tue, 12 Apr 2022 02:27:37 +0200 (CEST)
Date: Tue, 12 Apr 2022 02:27:37 +0200
From: Vincent Lefevre <vincent@HIDDEN>
To: Chet Ramey <chet.ramey@HIDDEN>
Subject: Re: bug#54785: for floating point, printf should use double like in
 C instead of long double
Message-ID: <20220412002737.GG25734@HIDDEN>
Mail-Followup-To: Vincent Lefevre <vincent@HIDDEN>,
 Chet Ramey <chet.ramey@HIDDEN>, Paul Eggert <eggert@HIDDEN>,
 bug-coreutils@HIDDEN, bug-bash@HIDDEN
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
 <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
X-Mailer-Info: https://www.vinc17.net/mutt/
User-Agent: Mutt/2.2.2+9 (f082dd14) vl-138565 (2022-03-25)
Received-SPF: none client-ip=155.133.131.76; envelope-from=vincent@HIDDEN;
 helo=joooj.vinc17.net
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
Cc: Paul Eggert <eggert@HIDDEN>, bug-coreutils@HIDDEN, bug-bash@HIDDEN
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: -3.3 (---)

On 2022-04-11 14:52:50 -0400, Chet Ramey wrote:
> It sounds like there are three cases.
> 
> 1. If the `L' modifier is supplied, as an extension (POSIX doesn't allow
>    length modifiers for the printf utility), use long double. This would
>    work in both default and posix modes.
> 
> 2. In posix mode, use strtod() and double.
> 
> 3. In default mode, use the existing code to get the highest possible
>    precision, as the code has done for over 20 years.

Do users really need more precision than double in the context of
bash (or Coreutils) printf?

Moreover, if the argument comes from a double written in decimal
(as often done), using more precision will actually show garbage
that was not present initially. This was how I found this issue
with Coreutils printf (as I expected parsing as a double, this
was very disturbing):

cventin% /usr/bin/printf "%a\n" $((12196067*2**(-22)))
0xb.a18e300000000d1p-2

Note also that the "long double" precision depends on the architecture,
so that this may confuse users who work with different architectures.

-- 
Vincent Lefvre <vincent@HIDDEN> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 11 Apr 2022 18:53:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 11 14:53:06 2022
Received: from localhost ([127.0.0.1]:45718 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ndz9q-0007tC-Qv
	for submit <at> debbugs.gnu.org; Mon, 11 Apr 2022 14:53:06 -0400
Received: from lists.gnu.org ([209.51.188.17]:52748)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <chet.ramey@HIDDEN>) id 1ndz9p-0007sn-2b
 for submit <at> debbugs.gnu.org; Mon, 11 Apr 2022 14:53:01 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:43268)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <chet.ramey@HIDDEN>)
 id 1ndz9o-0000mH-RE
 for bug-coreutils@HIDDEN; Mon, 11 Apr 2022 14:53:00 -0400
Received: from mpv1-2015.cwru.edu ([129.22.103.226]:54906
 helo=mpv1-2015.case.edu)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <chet.ramey@HIDDEN>)
 id 1ndz9m-0006JX-75
 for bug-coreutils@HIDDEN; Mon, 11 Apr 2022 14:53:00 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu;
 s=smtp-primary; t=1649703178;
 bh=i0t4K2eW5NQl+LztrK12fBWOnRlE2kC9WO095eKI6nw=;
 h=Message-ID:Date:MIME-Version:Reply-To:Cc:Subject:To:References:
 From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
 b=i5xmcOPX2i33fVglJEsXnhHd2kzH59Tjt2qGEYOhHSj/ZRi9HGJm+vN4zdE1cAgW9y
 vRQJwGwaHIpAg0Bm3O+RpBROGeF2PJ5w+kHxCkYG0aNx2Ffq3kDCDETsnjFEUzopCan
 C5jJP2Ez6Hc0CNkOUzoLpdcnYiZsQtoaIn6QKjQfIwhzKd1BaPLuoJ5fNBBmXiNpmeY
 T/x08UvdLijJOGM4oyu2E/fy2o1X9YSqXUxW/AoZuK/hNpZjF4RTw2fyDFX0KuyGX7s
 YurxFX3FU+diLfhqmsFx8R0mxc0w6ChidK0qqipirxnhTBA3pBETASeHM+IKm4/0wdM
 N99tUjyA==
Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234])
 by mpv1-2015.case.edu (MOS 4.4.8-GA FastPath queued)
 with ESMTP id CHO51271; Mon, 11 Apr 2022 14:52:55 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu;
 s=smtp-primary; t=1649703175;
 bh=i0t4K2eW5NQl+LztrK12fBWOnRlE2kC9WO095eKI6nw=;
 h=Message-ID:Date:MIME-Version:Reply-To:Cc:Subject:To:References:
 From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
 b=6kY3x6rRuHOLgAfAMxTqHtomN1+MiZJpL6VYVDjLqxLMphtOl2x/agiitGwaYrFnSv
 HmDdJn/lu/yF/YROSt+sgp3Tmxf1QEaFprMFaO9ttLMINrOY6RK3aXnLTuherUQO8UN
 A5xA9AdoQdUB5X7xBC2uh8SXk9cF5lC4sIHrUSMD7wnC3YVfRHS79XUi0NW5yTjICST
 dlw9mzEBQr/o9ZF98EVN/Lg8bExbyil1F0aBfftjr6L6ZpuA6xpQ9qDvzbD8eakm0NA
 1J1EBObuZ0v0EKFWMY5dW9b3k0cI86Y0oOo8Gwry/Rub47eGS0Np0K6u/2rtJpxRuKu
 h9YdYvqw==
Received: from mail-qv1-f71.google.com (EHLO mail-qv1-f71.google.com)
 ([209.85.219.71])
 by mpv5-2015.case.edu (MOS 4.4.8-GA FastPath queued)
 with ESMTP id HXE32881; Mon, 11 Apr 2022 14:52:55 -0400 (EDT)
Received: by mail-qv1-f71.google.com with SMTP id
 o15-20020a0562140e4f00b00443dee06cc4so16434149qvc.10
 for <bug-coreutils@HIDDEN>; Mon, 11 Apr 2022 11:52:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=g-case;
 h=message-id:date:mime-version:user-agent:reply-to:cc:subject
 :content-language:to:references:from:organization:in-reply-to
 :content-transfer-encoding;
 bh=BljJnRqacEhRfYDB/lTYOM8qRyNiEnxQKnGytVtNYco=;
 b=OzAkdVAC0icKy3ZGxFxmWX/FhsbEs6eOiWNA8IxCctmyMC1y5jEsSMUbY4DH1SGsOh
 4ZclLpXbrKc0yI5EAAT+UE3Eu4dFQdsrJuEyTZAcAAkuNJj+ZgR+69cfN4vJ+vNbcLoa
 O+wtLLZaw3OotZ6XYVratnOccD3p2QngcfB03K7i2uiumxGyi9N9Mubf6eztUXJWjQrB
 7oYH/pWeTnLHK6urUNKTndRcNQGI0fDGaUYTMJfgulIMqPz5gWQCHHBYIV7FRbwwm5My
 VYJ554utXQs/6fTlD8JIsH+MllzS3EBtpUWfrOUCA4Z4BWfWmNOpBq+sJr5waPmAQrtI
 kOJQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:message-id:date:mime-version:user-agent:reply-to
 :cc:subject:content-language:to:references:from:organization
 :in-reply-to:content-transfer-encoding;
 bh=BljJnRqacEhRfYDB/lTYOM8qRyNiEnxQKnGytVtNYco=;
 b=R0f2MLPpqaf58Q+vbSLjkUzJ7f2jPGcQ5YVbF4redmCk/ttL3NBVTo2jADE/djQkPf
 dyKfDQzslQSW6dIKogEEZIcbfgPb3d941REMpnb3sm+Z/1dF22TnpHVlaDyvJwuad4nE
 4ZE+wyD39qNQG/8sakf4RZnebeLOTiftIwN1qCqjSaKRERHADtTN6SdlnQEIMbH9vccE
 9AZthmyAKw75dAfMxwt9aOt1JYluxVcZCtbU3v9OyjXyH7YUWOyQx7kIRt+QdJUu2BWl
 dpaRVWYpTRUiqkSGOcF1LMFs+PyMDPMtUOKa2U74naLZffmlp5rl7NGf6EGfEIyG2VfV
 7jbQ==
X-Gm-Message-State: AOAM532jPDu4foRZQtzXUNAbOq8az7ODNdZuORh+wsyG59FjWR57Uzsx
 awnIIJcn5Bu40itcQcl6i7vsUzDPRnPRrcZ2tINyeHJiMp8NBAetxyjY9nQE/ytmQOTEeTwm45V
 aQtrHJ5rc++Hc4exl0Q==
X-Received: by 2002:a05:620a:4694:b0:67e:c9bf:3f9e with SMTP id
 bq20-20020a05620a469400b0067ec9bf3f9emr596492qkb.452.1649703174744; 
 Mon, 11 Apr 2022 11:52:54 -0700 (PDT)
X-Google-Smtp-Source: ABdhPJwu9LHYkFa8z38rXDnVibvHaNWymxmjq4N7iqyDSI0sG75WKtBOHhN1tp9ofIF8Mg1jUEU0Jg==
X-Received: by 2002:a05:620a:4694:b0:67e:c9bf:3f9e with SMTP id
 bq20-20020a05620a469400b0067ec9bf3f9emr596476qkb.452.1649703174426; 
 Mon, 11 Apr 2022 11:52:54 -0700 (PDT)
Received: from [10.3.0.32] (v129-22-118-111.tisvpn.cwru.edu. [129.22.118.111])
 by smtp.gmail.com with ESMTPSA id
 f12-20020a379c0c000000b0069a048e7f0bsm8522551qke.76.2022.04.11.11.52.52
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 11 Apr 2022 11:52:53 -0700 (PDT)
Message-ID: <b8cc8424-47bd-5536-c41f-6cb84f327643@HIDDEN>
Date: Mon, 11 Apr 2022 14:52:50 -0400
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
 Gecko/20100101 Thunderbird/91.8.0
Subject: Re: bug#54785: for floating point, printf should use double like in C
 instead of long double
Content-Language: en-US
To: Paul Eggert <eggert@HIDDEN>, Vincent Lefevre <vincent@HIDDEN>
References: <20220408091719.GA25734@HIDDEN>
 <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
From: Chet Ramey <chet.ramey@HIDDEN>
Organization: ITS, Case Western Reserve University
In-Reply-To: <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Mirapoint-IP-Reputation: reputation=Good-1, source=Queried,
 refid=tid=0001.0A742F8E.62547281.00AA, actions=tag
X-Mirapoint-Virus-RAPID-Raw: score=unknown(0),
 refid=str=0001.0A742F22.62547907.004C,ss=1,re=0.000,fgs=0,
 ip=0.0.0.0, so=2016-11-06 16:00:04,
 dmn=2011-05-27 18:58:46
X-Mirapoint-Loop-Id: 12112f829b1645671d0889986824b416
X-Mirapoint-IP-Reputation: reputation=good-1, source=Fixed, refid=n/a,
 actions=tag
X-Junkmail-Status: score=8/90, host=mpv1-2015.case.edu
X-Junkmail-PrAS-Raw: score=8/90, refid=2.7.2:2022.4.11.173323:17:8.317, ip=,
 rules=__YOUTUBE_RCVD, DKIM_SIGNATURE,
 __X_GOOGLE_DKIM_SIGNATURE, __X_GM_MESSAGE_STATE,
 __X_GOOGLE_SMTP_SOURCE, __HAS_MSGID, __SANE_MSGID,
 DATE_TZ_NA, __MIME_VERSION, __USER_AGENT,
 __MOZILLA_USER_AGENT, __HAS_REPLYTO, __HAS_CC_HDR,
 __MULTIPLE_RCPTS_CC_X2, __SUBJ_REPLY,
 __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT,
 __SUBJ_ALPHA_END, __TO_MALFORMED_2,
 __MULTIPLE_RCPTS_TO_X2, __TO_NAME,
 __TO_NAME_DIFF_FROM_ACC, __HAS_REFERENCES, __REFERENCES,
 __HAS_FROM, FROM_EDU_TLD, __IN_REP_TO, __CT,
 __CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY,
 __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC2,
 __HEADER_ORDER_FROM, __RCPT_DOMAIN_NOT_TO,
 __REPLYTO_SAMEAS_FROM_DOMAIN, __DKIM_ALIGNS_1,
 __DKIM_ALIGNS_2, __FUR_HEADER, __ANY_URI, __URI_MAILTO,
 __URI_WITH_PATH, __URI_ENDS_IN_SLASH, __URI_NO_WWW,
 __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY,
 __URI_NOT_IMG, [TRUNCATED], so=2010-03-03 19:42:08,
 dmn=2016-08-03-0138
Received-SPF: pass client-ip=129.22.103.226; envelope-from=chet.ramey@HIDDEN;
 helo=mpv1-2015.case.edu
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001,
 RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: bug-coreutils@HIDDEN, bug-bash@HIDDEN, chet.ramey@HIDDEN
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>
Reply-To: chet.ramey@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

On 4/9/22 3:31 PM, Paul Eggert wrote:

>> I suggest to parse the argument as a "long double" only if the "L"
>> length modifier is provided, like in C.
> Thanks, good idea.
> 
> I checked, and this also appears to be a POSIX conformance issue. POSIX 
>   says that floating point operands "shall be evaluated as if by the 
> strtod() function". This means double, not long double.
> 
> Whatever decision we make here, we should be consistent with Bash so I'll 
> cc this email to bug-bash.
> 
> I propose that we change both coreutils and Bash to use 'double' rather 
> than 'long double' here, unless the user specifies the L modifier (e.g., 
> "printf '%La\n' ...". I've written up a patch (attached) to Bash 5.2 alpha 
> to do that. Assuming the Bash maintainer likes this proposal, I plan to 
> implement something similar for Coreutils printf.

It sounds like there are three cases.

1. If the `L' modifier is supplied, as an extension (POSIX doesn't allow
    length modifiers for the printf utility), use long double. This would
    work in both default and posix modes.

2. In posix mode, use strtod() and double.

3. In default mode, use the existing code to get the highest possible
    precision, as the code has done for over 20 years.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@HIDDEN    http://tiswww.cwru.edu/~chet/




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 9 Apr 2022 19:31:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 09 15:31:35 2022
Received: from localhost ([127.0.0.1]:38710 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ndGo2-0001Rz-Nb
	for submit <at> debbugs.gnu.org; Sat, 09 Apr 2022 15:31:35 -0400
Received: from lists.gnu.org ([209.51.188.17]:60864)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1ndGo0-0001Rr-LD
 for submit <at> debbugs.gnu.org; Sat, 09 Apr 2022 15:31:33 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:54102)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eggert@HIDDEN>)
 id 1ndGo0-0001U8-8O; Sat, 09 Apr 2022 15:31:32 -0400
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41626)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eggert@HIDDEN>)
 id 1ndGnx-0002Pw-R3; Sat, 09 Apr 2022 15:31:31 -0400
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 95E5E160097;
 Sat,  9 Apr 2022 12:31:27 -0700 (PDT)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id jBpN4gfTCOxW; Sat,  9 Apr 2022 12:31:25 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9F8C916009E;
 Sat,  9 Apr 2022 12:31:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id rtjYPzQzRYeB; Sat,  9 Apr 2022 12:31:25 -0700 (PDT)
Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com
 [172.91.119.151])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 6A061160097;
 Sat,  9 Apr 2022 12:31:25 -0700 (PDT)
Content-Type: multipart/mixed; boundary="------------z6udf85Y52QgwRxm8Fqt07Fr"
Message-ID: <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@HIDDEN>
Date: Sat, 9 Apr 2022 12:31:24 -0700
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.7.0
Content-Language: en-US
To: Vincent Lefevre <vincent@HIDDEN>
References: <20220408091719.GA25734@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Subject: Re: bug#54785: for floating point, printf should use double like in C
 instead of long double
In-Reply-To: <20220408091719.GA25734@HIDDEN>
Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@HIDDEN;
 helo=zimbra.cs.ucla.edu
X-Spam_score_int: -41
X-Spam_score: -4.2
X-Spam_bar: ----
X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001,
 RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: bug-coreutils@HIDDEN, bug-bash@HIDDEN
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: -2.3 (--)

This is a multi-part message in MIME format.
--------------z6udf85Y52QgwRxm8Fqt07Fr
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Vincent Lefevre wrote in <https://bugs.gnu.org/54785>:

> $ zsh -fc '/usr/bin/printf "%a\n" $((43./2**22))'
> 0xa.c0000000000025cp-20
> 
> instead of
> 
> 0xa.cp-20

To summarize, this test case is:

printf '%a\n' 1.0251998901367188e-05

and the problem is that converting 1.0251998901367188e-05 to long double 
prints the too-precise "0xa.c0000000000025cp-20", whereas you want it to 
convert to double (which matches what most other programs do) and to 
print "0xa.cp-20" or equivalent.

> (Note that ksh uses long double internally, but does not ensure the
> round trip back to long double

Yes, ksh messes up here. However, it's more important for Coreutils 
printf to be compatible with the GNU shell, and Bash uses long double:

$ echo $BASH_VERSION
5.1.8(1)-release
$ /usr/bin/printf --version | head -n1
printf (GNU coreutils) 8.32
$ printf '%a\n' 1.0251998901367188e-05
0xa.c0000000000025cp-20
$ /usr/bin/printf '%a\n' 1.0251998901367188e-05
0xa.c0000000000025cp-20


> I suggest to parse the argument as a "long double" only if the "L"
> length modifier is provided, like in C.
Thanks, good idea.

I checked, and this also appears to be a POSIX conformance issue. POSIX 
  says that floating point operands "shall be evaluated as if by the 
strtod() function". This means double, not long double.

Whatever decision we make here, we should be consistent with Bash so 
I'll cc this email to bug-bash.

I propose that we change both coreutils and Bash to use 'double' rather 
than 'long double' here, unless the user specifies the L modifier (e.g., 
"printf '%La\n' ...". I've written up a patch (attached) to Bash 5.2 
alpha to do that. Assuming the Bash maintainer likes this proposal, I 
plan to implement something similar for Coreutils printf.
--------------z6udf85Y52QgwRxm8Fqt07Fr
Content-Type: text/x-patch; charset=UTF-8; name="bash-double.diff"
Content-Disposition: attachment; filename="bash-double.diff"
Content-Transfer-Encoding: base64

ZGlmZiAnLXgqficgLXBydSBiYXNoLTUuMi1hbHBoYS9idWlsdGlucy9wcmludGYuZGVmIGJh
c2gtNS4yLWFscGhhLWRvdWJsZS9idWlsdGlucy9wcmludGYuZGVmCi0tLSBiYXNoLTUuMi1h
bHBoYS9idWlsdGlucy9wcmludGYuZGVmCTIwMjEtMTItMjkgMTM6MDk6MjAuMDAwMDAwMDAw
IC0wODAwCisrKyBiYXNoLTUuMi1hbHBoYS1kb3VibGUvYnVpbHRpbnMvcHJpbnRmLmRlZgky
MDIyLTA0LTA5IDEyOjAyOjM1LjMzMDQ3NjA5NyAtMDcwMApAQCAtMjE1LDEzICsyMTUsMTQg
QEAgc3RhdGljIHVpbnRtYXhfdCBnZXR1aW50bWF4IFBBUkFNUygodm9pZAogCiAjaWYgZGVm
aW5lZCAoSEFWRV9MT05HX0RPVUJMRSkgJiYgSEFWRV9ERUNMX1NUUlRPTEQgJiYgIWRlZmlu
ZWQoU1RSVE9MRF9CUk9LRU4pCiB0eXBlZGVmIGxvbmcgZG91YmxlIGZsb2F0bWF4X3Q7Ci0j
ICBkZWZpbmUgRkxPQVRNQVhfQ09OVgkiTCIKKyMgIGRlZmluZSBVU0VfTE9OR19ET1VCTEUg
MQogIyAgZGVmaW5lIHN0cnRvZmx0bWF4CXN0cnRvbGQKICNlbHNlCiB0eXBlZGVmIGRvdWJs
ZSBmbG9hdG1heF90OwotIyAgZGVmaW5lIEZMT0FUTUFYX0NPTlYJIiIKKyMgIGRlZmluZSBV
U0VfTE9OR19ET1VCTEUgMAogIyAgZGVmaW5lIHN0cnRvZmx0bWF4CXN0cnRvZAogI2VuZGlm
CitzdGF0aWMgZG91YmxlIGdldGRvdWJsZSBQQVJBTVMoKHZvaWQpKTsKIHN0YXRpYyBmbG9h
dG1heF90IGdldGZsb2F0bWF4IFBBUkFNUygodm9pZCkpOwogCiBzdGF0aWMgaW50bWF4X3Qg
YXNjaWljb2RlIFBBUkFNUygodm9pZCkpOwpAQCAtMjQ3LDcgKzI0OCw3IEBAIHByaW50Zl9i
dWlsdGluIChsaXN0KQogICAgICBXT1JEX0xJU1QgKmxpc3Q7CiB7CiAgIGludCBjaCwgZmll
bGR3aWR0aCwgcHJlY2lzaW9uOwotICBpbnQgaGF2ZV9maWVsZHdpZHRoLCBoYXZlX3ByZWNp
c2lvbjsKKyAgaW50IGhhdmVfZmllbGR3aWR0aCwgaGF2ZV9wcmVjaXNpb24sIHVzZV9MbW9k
OwogICBjaGFyIGNvbnZjaCwgdGhpc2NoLCBuZXh0Y2gsICpmb3JtYXQsICptb2RzdGFydCwg
KnByZWNzdGFydCwgKmZtdCwgKnN0YXJ0OwogI2lmIGRlZmluZWQgKEhBTkRMRV9NVUxUSUJZ
VEUpCiAgIGNoYXIgbWJjaFsyNV07CQkvKiAyNSA+IE1CX0xFTl9NQVgsIHBsdXMgY2FuIGhh
bmRsZSA0LWJ5dGUgVVRGLTggYW5kIGxhcmdlIFVuaWNvZGUgY2hhcmFjdGVycyovCkBAIC00
MjIsOCArNDIzLDEyIEBAIHByaW50Zl9idWlsdGluIChsaXN0KQogCiAJICAvKiBza2lwIHBv
c3NpYmxlIGZvcm1hdCBtb2RpZmllcnMgKi8KIAkgIG1vZHN0YXJ0ID0gZm10OworCSAgdXNl
X0xtb2QgPSAwOwogCSAgd2hpbGUgKCpmbXQgJiYgc3RyY2hyIChMRU5NT0RTLCAqZm10KSkK
LQkgICAgZm10Kys7CisJICAgIHsKKwkgICAgICB1c2VfTG1vZCB8PSBVU0VfTE9OR19ET1VC
TEUgJiYgKmZtdCA9PSAnTCc7CisJICAgICAgZm10Kys7CisJICAgIH0KIAkgICAgCiAJICBp
ZiAoKmZtdCA9PSAwKQogCSAgICB7CkBAIC02OTQsMTEgKzY5OSwyNCBAQCBwcmludGZfYnVp
bHRpbiAobGlzdCkKICNlbmRpZgogCSAgICAgIHsKIAkJY2hhciAqZjsKLQkJZmxvYXRtYXhf
dCBwOwogCi0JCXAgPSBnZXRmbG9hdG1heCAoKTsKLQkJZiA9IG1rbG9uZyAoc3RhcnQsIEZM
T0FUTUFYX0NPTlYsIHNpemVvZihGTE9BVE1BWF9DT05WKSAtIDEpOwotCQlQRiAoZiwgcCk7
CisJCWlmICh1c2VfTG1vZCkKKwkJICB7CisJCSAgICBmbG9hdG1heF90IHA7CisKKwkJICAg
IHAgPSBnZXRmbG9hdG1heCAoKTsKKwkJICAgIGYgPSBta2xvbmcgKHN0YXJ0LCAiTCIsIDEp
OworCQkgICAgUEYgKGYsIHApOworCQkgIH0KKwkJZWxzZQorCQkgIHsKKwkJICAgIGRvdWJs
ZSBwOworCisJCSAgICBwID0gZ2V0ZG91YmxlICgpOworCQkgICAgZiA9IG1rbG9uZyAoc3Rh
cnQsICIiLCAwKTsKKwkJICAgIFBGIChmLCBwKTsKKwkJICB9CisKIAkJYnJlYWs7CiAJICAg
ICAgfQogCkBAIC0xMjQ4LDM1ICsxMjY2LDQwIEBAIGdldHVpbnRtYXggKCkKICAgcmV0dXJu
IChyZXQpOwogfQogCisjZGVmaW5lIGdldGZsb2F0KHJldCwgY29udmVydCkgXAorICBjaGFy
ICplcDsgXAorICBpZiAoZ2FyZ2xpc3QgPT0gMCkgXAorICAgIHJldHVybiAwOyBcCisgIGlm
IChnYXJnbGlzdC0+d29yZC0+d29yZFswXSA9PSAnXCcnIHx8IGdhcmdsaXN0LT53b3JkLT53
b3JkWzBdID09ICciJykgXAorICAgIHJldHVybiBhc2NpaWNvZGUgKCk7IFwKKyAgZXJybm8g
PSAwOyBcCisgIChyZXQpID0gKGNvbnZlcnQpIChnYXJnbGlzdC0+d29yZC0+d29yZCwgJmVw
KTsgXAorICBpZiAoKmVwKSBcCisgICAgeyBcCisgICAgICBzaF9pbnZhbGlkbnVtIChnYXJn
bGlzdC0+d29yZC0+d29yZCk7IFwKKyAgICAgIC8qIFNhbWUgdGhpbmcgYWJvdXQgUE9TSVgu
MiBjb252ZXJzaW9uIGVycm9yIHJlcXVpcmVtZW50cy4gKi8gXAorICAgICAgaWYgKDApIFwK
KyAgICAgICAgKHJldCkgPSAwOyBcCisgICAgICBjb252ZXJzaW9uX2Vycm9yID0gMTsgXAor
ICAgIH0gXAorICBlbHNlIGlmIChlcnJubyA9PSBFUkFOR0UpIFwKKyAgICBwcmludGZfZXJh
bmdlIChnYXJnbGlzdC0+d29yZC0+d29yZCk7IFwKKyAgZ2FyZ2xpc3QgPSBnYXJnbGlzdC0+
bmV4dAorCitzdGF0aWMgZG91YmxlCitnZXRkb3VibGUgKCkKK3sKKyAgZG91YmxlIHJldDsK
KyAgZ2V0ZmxvYXQgKHJldCwgc3RydG9kKTsKKyAgcmV0dXJuIHJldDsKK30KKwogc3RhdGlj
IGZsb2F0bWF4X3QKIGdldGZsb2F0bWF4ICgpCiB7CiAgIGZsb2F0bWF4X3QgcmV0OwotICBj
aGFyICplcDsKLQotICBpZiAoZ2FyZ2xpc3QgPT0gMCkKLSAgICByZXR1cm4gKDApOwotCi0g
IGlmIChnYXJnbGlzdC0+d29yZC0+d29yZFswXSA9PSAnXCcnIHx8IGdhcmdsaXN0LT53b3Jk
LT53b3JkWzBdID09ICciJykKLSAgICByZXR1cm4gYXNjaWljb2RlICgpOwotCi0gIGVycm5v
ID0gMDsKLSAgcmV0ID0gc3RydG9mbHRtYXggKGdhcmdsaXN0LT53b3JkLT53b3JkLCAmZXAp
OwotCi0gIGlmICgqZXApCi0gICAgewotICAgICAgc2hfaW52YWxpZG51bSAoZ2FyZ2xpc3Qt
PndvcmQtPndvcmQpOwotI2lmIDAKLSAgICAgIC8qIFNhbWUgdGhpbmcgYWJvdXQgUE9TSVgu
MiBjb252ZXJzaW9uIGVycm9yIHJlcXVpcmVtZW50cy4gKi8KLSAgICAgIHJldCA9IDA7Ci0j
ZW5kaWYKLSAgICAgIGNvbnZlcnNpb25fZXJyb3IgPSAxOwotICAgIH0KLSAgZWxzZSBpZiAo
ZXJybm8gPT0gRVJBTkdFKQotICAgIHByaW50Zl9lcmFuZ2UgKGdhcmdsaXN0LT53b3JkLT53
b3JkKTsKLQotICBnYXJnbGlzdCA9IGdhcmdsaXN0LT5uZXh0OwotICByZXR1cm4gKHJldCk7
CisgIGdldGZsb2F0IChyZXQsIHN0cnRvZmx0bWF4KTsKKyAgcmV0dXJuIHJldDsKIH0KIAog
LyogTk8gY2hlY2sgaXMgbmVlZGVkIGZvciBnYXJnbGlzdCBoZXJlLiAqLwpkaWZmICcteCp+
JyAtcHJ1IGJhc2gtNS4yLWFscGhhL0NIQU5HRVMgYmFzaC01LjItYWxwaGEtZG91YmxlL0NI
QU5HRVMKLS0tIGJhc2gtNS4yLWFscGhhL0NIQU5HRVMJMjAyMi0wMS0xMCAxNDoyMjoxNC4w
MDAwMDAwMDAgLTA4MDAKKysrIGJhc2gtNS4yLWFscGhhLWRvdWJsZS9DSEFOR0VTCTIwMjIt
MDQtMDkgMTE6NTg6MzYuNDczODgwNDAxIC0wNzAwCkBAIC0xNDIsNiArMTQyLDkgQEAgdXUu
IEZpeGVkIGEgcHJvYmxlbSB3aXRoIHF1b3Rpbmcgc2hlbGwgZQogICAgIHRoZXkgYXBwZWFy
IGluIGEgdGFiLWNvbXBsZXRlZCB3b3JkIGFsb25nIHdpdGggY2hhcmFjdGVycyB0aGF0IGRv
IG5lZWQKICAgICBxdW90aW5nIChlLmcuLiAkSE9NRS9WaXJ0dWFsQm94IFZNcykuCiAKK3Z2
LiBUaGUgcHJpbnRmIGJ1aWx0aW4gbm93IG9yZGluYXJpbHkgdXNlcyAnZG91YmxlJyBmb3Ig
ZmxvYXRpbmcgcG9pbnQKKyAgICBmb3JtYXRzIGxpa2UgJWcuICBVc2UgZm9ybWF0cyBsaWtl
ICVMZyBmb3IgJ2xvbmcgZG91YmxlJy4KKwogMi4gQ2hhbmdlcyB0byBSZWFkbGluZQogCiBh
LiBGaXhlZCBhIHByb2JsZW0gd2l0aCBjbGVhbmluZyB1cCBhY3RpdmUgbWFya3Mgd2hlbiB1
c2luZyBjYWxsYmFjayBtb2RlLgo=

--------------z6udf85Y52QgwRxm8Fqt07Fr--




Information forwarded to bug-coreutils@HIDDEN:
bug#54785; Package coreutils. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 8 Apr 2022 09:17:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 08 05:17:34 2022
Received: from localhost ([127.0.0.1]:33944 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nckkI-0003Ff-Kk
	for submit <at> debbugs.gnu.org; Fri, 08 Apr 2022 05:17:34 -0400
Received: from lists.gnu.org ([209.51.188.17]:38128)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vincent@HIDDEN>) id 1nckkH-0003FY-8j
 for submit <at> debbugs.gnu.org; Fri, 08 Apr 2022 05:17:33 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36718)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vincent@HIDDEN>)
 id 1nckkH-0000XR-3N
 for bug-coreutils@HIDDEN; Fri, 08 Apr 2022 05:17:33 -0400
Received: from joooj.vinc17.net ([155.133.131.76]:52804)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vincent@HIDDEN>)
 id 1nckkF-0007w7-J2
 for bug-coreutils@HIDDEN; Fri, 08 Apr 2022 05:17:32 -0400
Received: from smtp-zira.vinc17.net (128.119.75.86.rev.sfr.net [86.75.119.128])
 by joooj.vinc17.net (Postfix) with ESMTPSA id CBDE3E2;
 Fri,  8 Apr 2022 11:17:19 +0200 (CEST)
Received: by zira.vinc17.org (Postfix, from userid 1000)
 id 5EE9D2800208; Fri,  8 Apr 2022 11:17:19 +0200 (CEST)
Date: Fri, 8 Apr 2022 11:17:19 +0200
From: Vincent Lefevre <vincent@HIDDEN>
To: bug-coreutils@HIDDEN
Subject: for floating point, printf should use double like in C instead of
 long double
Message-ID: <20220408091719.GA25734@HIDDEN>
Mail-Followup-To: Vincent Lefevre <vincent@HIDDEN>, bug-coreutils@HIDDEN
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
X-Mailer-Info: https://www.vinc17.net/mutt/
User-Agent: Mutt/2.2.2+9 (f082dd14) vl-138565 (2022-03-25)
Received-SPF: none client-ip=155.133.131.76; envelope-from=vincent@HIDDEN;
 helo=joooj.vinc17.net
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
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: -3.3 (---)

The printf command assumes that floating-point arguments are long double
values, which can yield surprising results, while most of the time the
double type is assumed by applications (for instance, this is the case
of XPath).

For instance:

$ zsh -fc '/usr/bin/printf "%a\n" $((43./2**22))'
0xa.c0000000000025cp-20

instead of

0xa.cp-20

(Note that ksh uses long double internally, but does not ensure the
round trip back to long double, so that this is incorrect anyway; see
https://unix.stackexchange.com/questions/422122/why-does-0-1-expand-to-0-10000000000000001-in-zsh
by Stephane Chazelas.)

I suppose that the issue is at the parsing level (after parsing the
value as a double, i.e. rounding to a double, the resulting binary
value can internally be stored either in a double or a long double
without changing its value).

I suggest to parse the argument as a "long double" only if the "L"
length modifier is provided, like in C.

-- 
Vincent Lefvre <vincent@HIDDEN> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Acknowledgement sent to Vincent Lefevre <vincent@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#54785; 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: Wed, 27 Apr 2022 19:00:02 UTC

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