From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Vincent Lefevre Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 08 Apr 2022 09:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 54785@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164940945412507 (code B ref -1); Fri, 08 Apr 2022 09:18:01 +0000 Received: (at submit) by debbugs.gnu.org; 8 Apr 2022 09:17:34 +0000 Received: from localhost ([127.0.0.1]:33944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nckkI-0003Ff-Kk for submit@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 ) id 1nckkH-0003FY-8j for submit@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 ) id 1nckkH-0000XR-3N for bug-coreutils@gnu.org; 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 ) id 1nckkF-0007w7-J2 for bug-coreutils@gnu.org; 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 Message-ID: <20220408091719.GA25734@zira.vinc17.org> Mail-Followup-To: Vincent Lefevre , bug-coreutils@gnu.org 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@vinc17.net; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sat, 09 Apr 2022 19:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Vincent Lefevre Cc: 54785@debbugs.gnu.org, bug-bash@gnu.org X-Debbugs-Original-Cc: bug-coreutils@gnu.org, bug-bash@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16495326955584 (code B ref -1); Sat, 09 Apr 2022 19:32:02 +0000 Received: (at submit) by debbugs.gnu.org; 9 Apr 2022 19:31:35 +0000 Received: from localhost ([127.0.0.1]:38710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndGo2-0001Rz-Nb for submit@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 ) id 1ndGo0-0001Rr-LD for submit@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 ) 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 ) 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@cs.ucla.edu> 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 References: <20220408091719.GA25734@zira.vinc17.org> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <20220408091719.GA25734@zira.vinc17.org> Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 : > $ 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-- From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Chet Ramey Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 11 Apr 2022 18:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert , Vincent Lefevre Cc: 54785@debbugs.gnu.org, bug-bash@gnu.org, chet.ramey@case.edu X-Debbugs-Original-Cc: bug-coreutils@gnu.org, bug-bash@gnu.org, chet.ramey@case.edu Reply-To: chet.ramey@case.edu Received: via spool by submit@debbugs.gnu.org id=B.164970318630337 (code B ref -1); Mon, 11 Apr 2022 18:54:01 +0000 Received: (at submit) by debbugs.gnu.org; 11 Apr 2022 18:53:06 +0000 Received: from localhost ([127.0.0.1]:45718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndz9q-0007tC-Qv for submit@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 ) id 1ndz9p-0007sn-2b for submit@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 ) id 1ndz9o-0000mH-RE for bug-coreutils@gnu.org; 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 ) id 1ndz9m-0006JX-75 for bug-coreutils@gnu.org; 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 ; 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: 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 Content-Language: en-US References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> From: Chet Ramey Organization: ITS, Case Western Reserve University In-Reply-To: <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> 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@case.edu; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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@case.edu http://tiswww.cwru.edu/~chet/ From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Vincent Lefevre Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 12 Apr 2022 00:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Chet Ramey Cc: eggert@cs.ucla.edu, 54785@debbugs.gnu.org, bug-bash@gnu.org X-Debbugs-Original-Cc: Paul Eggert , bug-coreutils@gnu.org, bug-bash@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16497232737183 (code B ref -1); Tue, 12 Apr 2022 00:28:02 +0000 Received: (at submit) by debbugs.gnu.org; 12 Apr 2022 00:27:53 +0000 Received: from localhost ([127.0.0.1]:46489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ne4Ns-0001rn-W4 for submit@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 ) id 1ne4Nr-0001rg-ON for submit@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 ) 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 ) 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 Message-ID: <20220412002737.GG25734@zira.vinc17.org> Mail-Followup-To: Vincent Lefevre , Chet Ramey , Paul Eggert , bug-coreutils@gnu.org, bug-bash@gnu.org References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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@vinc17.net; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 25 Apr 2022 15:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: chet.ramey@case.edu Cc: vincent@vinc17.net, 54785@debbugs.gnu.org, bug-bash@gnu.org X-Debbugs-Original-Cc: Vincent Lefevre , bug-coreutils@gnu.org, bug-bash@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16508990089341 (code B ref -1); Mon, 25 Apr 2022 15:04:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 Apr 2022 15:03:28 +0000 Received: from localhost ([127.0.0.1]:35799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nj0FL-0002QZ-Uv for submit@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 ) id 1nj0FJ-0002Q2-HK for submit@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 ) 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 ) 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: 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 References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: 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@cs.ucla.edu; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Chet Ramey Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 25 Apr 2022 18:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: vincent@vinc17.net, 54785@debbugs.gnu.org, bug-bash@gnu.org, chet.ramey@case.edu X-Debbugs-Original-Cc: Vincent Lefevre , bug-coreutils@gnu.org, bug-bash@gnu.org, chet.ramey@case.edu Reply-To: chet.ramey@case.edu Received: via spool by submit@debbugs.gnu.org id=B.16509109649256 (code B ref -1); Mon, 25 Apr 2022 18:23:01 +0000 Received: (at submit) by debbugs.gnu.org; 25 Apr 2022 18:22:44 +0000 Received: from localhost ([127.0.0.1]:36045 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nj3MB-0002PE-NN for submit@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 ) id 1nj3M5-0002P1-EK for submit@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 ) id 1nj3M4-0007Oc-9B for bug-coreutils@gnu.org; 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 ) id 1nj3Ly-0001Bm-VA for bug-coreutils@gnu.org; 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 ; 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@case.edu> 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 Content-Language: en-US References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> From: Chet Ramey Organization: ITS, Case Western Reserve University In-Reply-To: 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@case.edu; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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@case.edu http://tiswww.cwru.edu/~chet/ From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 25 Apr 2022 19:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: chet.ramey@case.edu Cc: vincent@vinc17.net, 54785@debbugs.gnu.org, bug-bash@gnu.org Received: via spool by 54785-submit@debbugs.gnu.org id=B54785.165091360713475 (code B ref 54785); Mon, 25 Apr 2022 19:07:02 +0000 Received: (at 54785) by debbugs.gnu.org; 25 Apr 2022 19:06:47 +0000 Received: from localhost ([127.0.0.1]:36108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nj42p-0003VG-MY for submit@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 ) id 1nj42n-0003V3-Ku for 54785@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@cs.ucla.edu> 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 Content-Language: en-US References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: "Glenn Golden" Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 25 Apr 2022 23:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 54785@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.165093068316099 (code B ref -1); Mon, 25 Apr 2022 23:52:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 Apr 2022 23:51:23 +0000 Received: from localhost ([127.0.0.1]:36336 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nj8UE-0004Ba-Tb for submit@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 ) id 1nj8UD-0004BT-50 for submit@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 ) id 1nj8UC-0003xy-Sc for bug-coreutils@gnu.org; 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 ) id 1nj8UA-0001Eu-Ts for bug-coreutils@gnu.org; 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 ; 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: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddvgddviecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesthdtre dtreertdenucfhrhhomhepfdfilhgvnhhnucfiohhluggvnhdfuceoghgughesiihplhgr nhgvrdgtohhmqeenucggtffrrghtthgvrhhnpeeuueeufeefhfetgedtjedtffehjeetve dtheehvdehtefhfedthefftdeujeelteenucffohhmrghinhepghhnuhdrohhrghenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgughgseiiph hlrghnvgdrtghomh X-ME-Proxy: 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: In-Reply-To: <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> Date: Mon, 25 Apr 2022 17:50:54 -0600 From: "Glenn Golden" Content-Type: text/plain Received-SPF: pass client-ip=64.147.123.24; envelope-from=gdg@zplane.com; 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 26 Apr 2022 01:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Glenn Golden , 54785@debbugs.gnu.org Received: via spool by 54785-submit@debbugs.gnu.org id=B54785.165093681826361 (code B ref 54785); Tue, 26 Apr 2022 01:34:02 +0000 Received: (at 54785) by debbugs.gnu.org; 26 Apr 2022 01:33:38 +0000 Received: from localhost ([127.0.0.1]:36457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1njA5C-0006r7-67 for submit@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 ) id 1njA5A-0006qs-H0 for 54785@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@cs.ucla.edu> 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 Content-Language: en-US References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: "Glenn Golden" Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 27 Apr 2022 12:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: "Paul Eggert" , 54785@debbugs.gnu.org Received: via spool by 54785-submit@debbugs.gnu.org id=B54785.165106146412183 (code B ref 54785); Wed, 27 Apr 2022 12:12:02 +0000 Received: (at 54785) by debbugs.gnu.org; 27 Apr 2022 12:11:04 +0000 Received: from localhost ([127.0.0.1]:41450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1njgVb-0003AR-Gr for submit@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 ) id 1njgVV-00039l-3M for 54785@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: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehgdeghecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfifhlvghn nhcuifholhguvghnfdcuoehgughgseiiphhlrghnvgdrtghomheqnecuggftrfgrthhtvg hrnhepueeuueeffefhteegtdejtdffheejteevtdehhedvheethfeftdehffdtueejleet necuffhomhgrihhnpehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepghgughesiihplhgrnhgvrdgtohhm X-ME-Proxy: 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@www.fastmail.com> In-Reply-To: <58c50895-153f-3c30-0e08-e31ad6173ef1@cs.ucla.edu> References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> <58c50895-153f-3c30-0e08-e31ad6173ef1@cs.ucla.edu> Date: Wed, 27 Apr 2022 06:10:21 -0600 From: "Glenn Golden" Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 27 Apr 2022 17:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Glenn Golden Cc: 54785@debbugs.gnu.org Received: via spool by 54785-submit@debbugs.gnu.org id=B54785.165108033226549 (code B ref 54785); Wed, 27 Apr 2022 17:26:01 +0000 Received: (at 54785) by debbugs.gnu.org; 27 Apr 2022 17:25:32 +0000 Received: from localhost ([127.0.0.1]:44251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1njlPw-0006u9-Hb for submit@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 ) id 1njlPu-0006to-7a for 54785@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@cs.ucla.edu> 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 Content-Language: en-US References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> <58c50895-153f-3c30-0e08-e31ad6173ef1@cs.ucla.edu> <3e4418f6-1ee8-44cf-bf11-fa555156ae94@www.fastmail.com> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <3e4418f6-1ee8-44cf-bf11-fa555156ae94@www.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Andreas Schwab Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 27 Apr 2022 18:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: Glenn Golden , 54785@debbugs.gnu.org Received: via spool by 54785-submit@debbugs.gnu.org id=B54785.165108555321039 (code B ref 54785); Wed, 27 Apr 2022 18:53:01 +0000 Received: (at 54785) by debbugs.gnu.org; 27 Apr 2022 18:52:33 +0000 Received: from localhost ([127.0.0.1]:44433 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1njmm9-0005TH-MO for submit@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 ) id 1njmm7-0005T8-Tr for 54785@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 References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> <58c50895-153f-3c30-0e08-e31ad6173ef1@cs.ucla.edu> <3e4418f6-1ee8-44cf-bf11-fa555156ae94@www.fastmail.com> <89b811d1-8956-e4d4-14d6-3c096c5e5728@cs.ucla.edu> 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@cs.ucla.edu> (Paul Eggert's message of "Wed, 27 Apr 2022 10:25:23 -0700") Message-ID: <87ilqu5pg5.fsf@igel.home> 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Chet Ramey Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 29 Apr 2022 20:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: vincent@vinc17.net, 54785@debbugs.gnu.org, bug-bash@gnu.org, chet.ramey@case.edu Reply-To: chet.ramey@case.edu Received: via spool by 54785-submit@debbugs.gnu.org id=B54785.165126271122314 (code B ref 54785); Fri, 29 Apr 2022 20:06:02 +0000 Received: (at 54785) by debbugs.gnu.org; 29 Apr 2022 20:05:11 +0000 Received: from localhost ([127.0.0.1]:55397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkWrW-0005no-VH for submit@debbugs.gnu.org; Fri, 29 Apr 2022 16:05:11 -0400 Received: from mpv4-2015.cwru.edu ([129.22.103.195]:53303 helo=mpv4-2015.case.edu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkWrV-0005ne-3O for 54785@debbugs.gnu.org; Fri, 29 Apr 2022 16:05:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1651262709; bh=hSS5EkxxaLQzd/secVQr760x81BysoQXsaTZP/Zd0vE=; h=Message-ID:Date:MIME-Version:Reply-To:Cc:Subject:To:References: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=GzumRddYHtTpljbchArzp0a9hVF9dDB6XNJgoe9k75J+23tP7CrdGUVuSqPPLgyMoM QAHYxgX4VOXmiPuUJcJ1mQPnOxWds5KN6UzOFOOKEyhrTqlEIEVTlrbhvlIgQGX/1pr ev4VUArpgu+ShXJFGwv231cTG7d0kbXu+bC4hNSLjF+tiP+aaTUexOs0HKgy4KsDa1k uBmtWvs2VgYzkMrzxMoho756vMh/zqiB2RNxWt3Em/bqoVXkbvSk1LS7pg7dUJv4RbY +/YK/GLUGOGUsRa53u4edlx+De+OmE9+e/n7JRTiaSK06m8aMtC7U4LWw9S0XJacxou +enk2pNg== Received: from mpv5-2015.CWRU.Edu (EHLO mpv5-2015.case.edu) ([129.22.103.234]) by mpv4-2015.case.edu (MOS 4.4.8-GA FastPath queued) with ESMTP id CGO32820; Fri, 29 Apr 2022 16:05:08 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1651262708; bh=hSS5EkxxaLQzd/secVQr760x81BysoQXsaTZP/Zd0vE=; h=Message-ID:Date:MIME-Version:Reply-To:Cc:Subject:To:References: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=1NHm+uke0AJo68fOBg1FwxJAuo/E2uueSi2iu0IpTvrptmXYM25vzXK3OPZfmTnF4F u/pYjkH+/xk/lDH6K213tjZXNcGGz+3FTIMlQgPZw2wyRHQxHNYRjR6TfsrUolyI5vl I6EoUKG8F9u05XUqJHRwSXVnejhSf5SWJTMY8/Ur7QfHkkCqutn48D4gmxvfPPYF2oE k7jlMDmLt8ob5sQxw3exONEUYIEPmCpPrU2C/miKQxitponbq2/VfHs7ruiR3XhkeeF xPwWy0I30Fad805EqlcWqYqsVYtckI/PaqPRrxHGvWX9MMX8QCiJbS9nHYHKU8vwZoh SnwzjBtw== Received: from mail-qt1-f199.google.com (EHLO mail-qt1-f199.google.com) ([209.85.160.199]) by mpv5-2015.case.edu (MOS 4.4.8-GA FastPath queued) with ESMTP id IAG02181; Fri, 29 Apr 2022 16:05:00 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id j18-20020ac806d2000000b002f354e9bc9eso6421302qth.10 for <54785@debbugs.gnu.org>; Fri, 29 Apr 2022 13:05:00 -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=Rx+Qulfb2OXOkw/FZdSEQLlUW8rvfxLmbK1WfoGvQmI=; b=SMW9d1UQBIiLktKdb3Pb+n1fwHN39rkG6RzeV5qmlB+ykkfXgT2MbhE8mMc17kXNiR J/GViUmUB68xJtAtYDQVuHDbVrhKjXu1eFGP1jugBE+3TjlyrQMy1AtAWrE41TzgncXq SSr0NbbGD0+CdiTtADewMEQTaIA+Dz45Iy/MKRULG/mVZL0WES8jkrgWOBg3F/eTw4Zo CmdWaY/vAVMK/ngHoXRGYeOeV8CcvddSYO0/iJWhP/4sAmgBwiKhBvPKISmRvKbBxrsz 44zz9tzry961Tnt+TbOn9QZyj6uQs1zTjCUIfplzHRwu/cL7pB3lMqKmJm+PbtXlZQXn oMog== 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=Rx+Qulfb2OXOkw/FZdSEQLlUW8rvfxLmbK1WfoGvQmI=; b=6JJpVD40qfUjFyUxi9m1qf/U/RkYrdRVl90YberzOb66K7YB8zzI01hd/MZ33tPD5v NmSvtjqAjr9I2A2K9fwD27r6D8NAPJhXd5n60cLcC7QSn0fsIq1Erd9YnyX3Wb21SDlg fTi4KAg1O45LVXyoSpY9Ue4+IKDE0Utod1ZSkw95+eW5M4Gs990ex3NQjGvAIrokROTT qAZqQAXfN8PpGx1Z/qusRnoi+BUgLM3JQ9jr9oPIMF4TpNcm9qNsfVR3o7YrH4wLbtCJ nx8TUb7H9iIdtrtQ+MZN+rGGE+jnkfXbKn1cKHGXOGLzRsUR1z3H5IpnfBy9R6is0AO8 Ld+Q== X-Gm-Message-State: AOAM530sPNt1DBlbuH1dZGXJ28ARESOujkscvds25y3QQrM32Z9SyvFK MCJipLCDZ6chs7k/AoltSu4lnozygsKqYcr9v8S7V45GBqTxPWHdEy0/0BJKXItbmUm4sAjJ0x4 5vntdiZiz3MpK/OQ2CA== X-Received: by 2002:ad4:4eea:0:b0:446:62cd:3c8f with SMTP id dv10-20020ad44eea000000b0044662cd3c8fmr633187qvb.18.1651262700324; Fri, 29 Apr 2022 13:05:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY2S5rtgucc0Lu6ZdBa+sPLMnCUJHkkszv4pRNz4gy2Lhs4nm/uROpE3wVQ+gGNDmN0u4d9w== X-Received: by 2002:ad4:4eea:0:b0:446:62cd:3c8f with SMTP id dv10-20020ad44eea000000b0044662cd3c8fmr633171qvb.18.1651262700073; Fri, 29 Apr 2022 13:05:00 -0700 (PDT) Received: from [192.168.0.112] (cpe-107-10-247-26.neo.res.rr.com. [107.10.247.26]) by smtp.gmail.com with ESMTPSA id l26-20020ac848da000000b002f39b99f6b7sm85598qtr.81.2022.04.29.13.04.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Apr 2022 13:04:59 -0700 (PDT) Message-ID: Date: Fri, 29 Apr 2022 16:04:58 -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 Content-Language: en-US References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> From: Chet Ramey Organization: ITS, Case Western Reserve University In-Reply-To: <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mirapoint-IP-Reputation: reputation=Good-1, source=Queried, refid=tid=0001.0A742F92.626C4429.003F, actions=tag X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A742F21.626C44EF.0017,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=mpv4-2015.case.edu X-Junkmail-PrAS-Raw: score=8/90, refid=2.7.2:2022.4.29.192725: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, __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, __MAIL_CHAIN, [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 4/25/22 3:06 PM, Paul Eggert wrote: > 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. I think I'm going to stick with the behavior I proposed, fixing the POSIX conformance issue and preserving backwards compatibility, until I hear more about whether backwards compatibility is an issue here. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/ From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 29 Apr 2022 23:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: chet.ramey@case.edu Cc: vincent@vinc17.net, 54785@debbugs.gnu.org, bug-bash@gnu.org Received: via spool by 54785-submit@debbugs.gnu.org id=B54785.16512741978725 (code B ref 54785); Fri, 29 Apr 2022 23:17:01 +0000 Received: (at 54785) by debbugs.gnu.org; 29 Apr 2022 23:16:37 +0000 Received: from localhost ([127.0.0.1]:55601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkZqn-0002Gf-99 for submit@debbugs.gnu.org; Fri, 29 Apr 2022 19:16:37 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:57476) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkZql-0002GR-Jp for 54785@debbugs.gnu.org; Fri, 29 Apr 2022 19:16:35 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 66A1116006C; Fri, 29 Apr 2022 16:16:29 -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 1sGKhSym4_vz; Fri, 29 Apr 2022 16:16:28 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 94FDB16007E; Fri, 29 Apr 2022 16:16:28 -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 uRW3ZSRM-Ucp; Fri, 29 Apr 2022 16:16:28 -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 6B37A16006C; Fri, 29 Apr 2022 16:16:28 -0700 (PDT) Message-ID: <7d575243-6751-c4dd-b63d-841f33ad0ac1@cs.ucla.edu> Date: Fri, 29 Apr 2022 16:16:28 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Content-Language: en-US References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 4/29/22 13:04, Chet Ramey wrote: > > I think I'm going to stick with the behavior I proposed, fixing the POSIX > conformance issue and preserving backwards compatibility, until I hear more > about whether backwards compatibility is an issue here. Come to think of it, as far as POSIX is concerned Bash doesn't need to change what it does. POSIX doesn't require that the shelll printf command be compiled with any particular environment. It would conform to POSIX, for example, if Bash's printf were compiled with an IBM floating point implementation rather than with an IEEE floating point implementation, so long as Bash's printf parses floating-point strings the way strtod is supposed to parse strings on an IBM mainframe. Similarly, Bash's printf can use an 80-bit floating point format if available; it will still conform to POSIX. So this isn't a POSIX conformance issue; only a compatibility issue. Is it more important for the Bash printf to behave like most other shells and other programs, or is it more important for Bash printf to behave like it has for the last 18 years or so? From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Vincent Lefevre Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sat, 30 Apr 2022 12:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Paul Eggert Cc: 54785@debbugs.gnu.org, bug-bash@gnu.org, chet.ramey@case.edu Received: via spool by 54785-submit@debbugs.gnu.org id=B54785.165132290817938 (code B ref 54785); Sat, 30 Apr 2022 12:49:01 +0000 Received: (at 54785) by debbugs.gnu.org; 30 Apr 2022 12:48:28 +0000 Received: from localhost ([127.0.0.1]:56100 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkmWS-0004fG-IH for submit@debbugs.gnu.org; Sat, 30 Apr 2022 08:48:28 -0400 Received: from joooj.vinc17.net ([155.133.131.76]:59550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkmWQ-0004f7-4t for 54785@debbugs.gnu.org; Sat, 30 Apr 2022 08:48:27 -0400 Received: from smtp-zira.vinc17.net (unknown [IPv6:2a01:cb19:869c:7700:6150:861a:e24c:595d]) by joooj.vinc17.net (Postfix) with ESMTPSA id 838D22F; Sat, 30 Apr 2022 14:48:24 +0200 (CEST) Received: by zira.vinc17.org (Postfix, from userid 1000) id 0F21C2800324; Sat, 30 Apr 2022 14:48:23 +0200 (CEST) Date: Sat, 30 Apr 2022 14:48:23 +0200 From: Vincent Lefevre Message-ID: <20220430124823.GD21872@zira.vinc17.org> Mail-Followup-To: Vincent Lefevre , Paul Eggert , chet.ramey@case.edu, 54785@debbugs.gnu.org, bug-bash@gnu.org References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> <7d575243-6751-c4dd-b63d-841f33ad0ac1@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7d575243-6751-c4dd-b63d-841f33ad0ac1@cs.ucla.edu> X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.2.3+10 (6e7437c4) vl-138565 (2022-04-12) X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 2022-04-29 16:16:28 -0700, Paul Eggert wrote: > On 4/29/22 13:04, Chet Ramey wrote: > > I think I'm going to stick with the behavior I proposed, fixing the POSIX > > conformance issue and preserving backwards compatibility, until I hear more > > about whether backwards compatibility is an issue here. > > Come to think of it, as far as POSIX is concerned Bash doesn't need to > change what it does. POSIX doesn't require that the shelll printf command be > compiled with any particular environment. It would conform to POSIX, for > example, if Bash's printf were compiled with an IBM floating point > implementation rather than with an IEEE floating point implementation, so > long as Bash's printf parses floating-point strings the way strtod is > supposed to parse strings on an IBM mainframe. Similarly, Bash's printf can > use an 80-bit floating point format if available; it will still conform to > POSIX. Yes, but to be clear, POSIX says: shall be evaluated as if by the strtod() function if the corresponding conversion specifier is a, A, e, E, f, F, g, or G so the number should be regarded as a double-precision number (type double). Then this number can be stored in a long double since any double is representable exactly as a long double. > So this isn't a POSIX conformance issue; only a compatibility issue. Is it > more important for the Bash printf to behave like most other shells and > other programs, or is it more important for Bash printf to behave like it > has for the last 18 years or so? Concerning the compatibility, the question is: with what? * If the goal is to communicate with other tools (e.g. zsh, XPath-based, but also programs that output values in decimal from double, which is the most common type used in practice), then double should be used. * If the goal is to communicate with other machines, then double is again preferable, since the long double type depends on the platform (x86, powerpc and aarch64 using 3 different formats). * Concerning just a bash script running on some machine: - If printf (without a length modifier) switches to double, the behavior will change. - Note that the behavior of the script on different platforms will be different if long double is used, but will be the same if double is used. Note that since bash doesn't support FP arithmetic in its arithmetic expressions, it is very probable that FP values provided to printf come from other tools (first point above), thus are probably in double precision. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) From unknown Sun Jun 15 08:42:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#54785: for floating point, printf should use double like in C instead of long double Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Sat, 30 Apr 2022 16:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54785 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Vincent Lefevre Cc: 54785@debbugs.gnu.org, bug-bash@gnu.org, chet.ramey@case.edu Received: via spool by 54785-submit@debbugs.gnu.org id=B54785.165133793930052 (code B ref 54785); Sat, 30 Apr 2022 16:59:02 +0000 Received: (at 54785) by debbugs.gnu.org; 30 Apr 2022 16:58:59 +0000 Received: from localhost ([127.0.0.1]:58983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkqQs-0007oe-MN for submit@debbugs.gnu.org; Sat, 30 Apr 2022 12:58:58 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:44626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkqQr-0007oR-Mu for 54785@debbugs.gnu.org; Sat, 30 Apr 2022 12:58:57 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4AD9F1600BE; Sat, 30 Apr 2022 09:58:51 -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 Rq3V0WGibS8Q; Sat, 30 Apr 2022 09:58:49 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 018F51600C2; Sat, 30 Apr 2022 09:58:49 -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 ONow3zC06P3P; Sat, 30 Apr 2022 09:58:48 -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 B4EB91600BE; Sat, 30 Apr 2022 09:58:48 -0700 (PDT) Message-ID: <3c4937e3-6f1f-3612-9b80-d38476fc14de@cs.ucla.edu> Date: Sat, 30 Apr 2022 09:58:47 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Content-Language: en-US References: <20220408091719.GA25734@zira.vinc17.org> <9f9ec602-c7ab-7e3b-207a-a60c96e23a08@cs.ucla.edu> <7ae2a577-7a8d-b70f-e023-0d0085f20776@case.edu> <54cfdfd5-bed7-c43f-f679-653bca79420e@cs.ucla.edu> <7d575243-6751-c4dd-b63d-841f33ad0ac1@cs.ucla.edu> <20220430124823.GD21872@zira.vinc17.org> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <20220430124823.GD21872@zira.vinc17.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) On 4/30/22 05:48, Vincent Lefevre wrote: > Yes, but to be clear, POSIX says: > > shall be evaluated as if by the strtod() function if the > corresponding conversion specifier is a, A, e, E, f, F, g, or G > > so the number should be regarded as a double-precision number > (type double). Yes, but POSIX does not require the C type 'double' and the C function strtod to be implemented via IEEE-754 64-bit floating point. POSIX allows 'double' and 'strtod' to be implemented via x86-64 extended-precision (80-bit) floating point, or by any other floating-point type that satisfies some (weak) properties. I see no requirement that the shell must be implemented as if by the standard c99 command with the default options. The POSIX requirements on the implementation of 'double' and 'strtod' are so lax that Bash 'printf' could even use IEEE-754 32-bit floating point, if it wanted to. One could build Bash with 'gcc -mlong-double=32 -mdouble=32' assuming these options work, and the result would conform to POSIX. (Not that I'm suggesting this!) > Concerning the compatibility, the question is: with what? I agree that it'd be a net win for Bash to use plain 'double' here; your discussion of the various compatibility plusses of doing that is compelling to me.