From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 779 invoked by alias); 27 Feb 2018 15:33:19 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42407 Received: (qmail 11245 invoked by uid 1010); 27 Feb 2018 15:33:19 -0000 X-Qmail-Scanner-Diagnostics: from park01.gkg.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(205.235.26.22):SA:0(-1.4/5.0):. Processed in 1.344929 secs); 27 Feb 2018 15:33:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_PASS,T_DKIM_INVALID,T_RP_MATCHES_RCVD autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: SRS0=otpN=FV=yahoo.co.uk=okiddle@bounces.park01.gkg.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: by amavisd-new at gkg.net Authentication-Results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1519745153; bh=USgetw0QZWuIAE3Ewa4Qx7cGEP9fn0i6ZcxLY9XahTM=; h=From:References:To:Subject:Date:From:Subject; b=QOr7onytGTO81QbXkB0sGfIIgTDs8Y6Hf0NfclHX7eMqtRX7du6tYvyKHX0Xjd1NeK4NVMr4kiERnN1DqhnDMCZpvIiHmpCfn0/xH/PEJZX74Ta7PIw32WfznwJYiuuFuhf6ma8sl9EFrJk2m5TmHlntly9Kv+MDXnTtNVB7wODMXLYWk9i0XTM0SYtlvbKOTNr3Skq+OJb2Y3WpglYbLu3Mqq8lIeKeb7rIiz273XkCUfK9jSfzfCMEv1XMZrCW9QOGN2WrvNmrlqYmtUnNx8+GjH2BbnLt0Fvs3hfvH56Kg/SPqSNvIbg5q8n2rALa9AwokIR3iL1YufhHe+VuIA== X-YMail-OSG: M..OGu8VM1laxVYX.yMUyGNl4w3CSrgNuKlUkHJfM0bJAxRDTHtIpc0cwafaT7F cR7GArCl11xsFUXE5YT4PwP0XBhj5h5LczD86sCyBCYcFVkvC12iHLVcgZvRvvJe6EI9Qd3DHGoX OyUR63xv9WFZhpKVxExOgHPkSE9xZAn_79gfB1FJ4anyd0w10rB7iitVgIuqy26i1_MbdN_DRVmm tspZ5U6c.Q5hfuuL4LHMiM8V1oPnZxjj.U7komuqgFITPwOiIZMlOKFz5u2DJvRybH_o1LJVz0jA KvW40OhQSam1ITlg0H04Xh8UHaEahTWgrl0cZh8sAEm5ucTRDC6EaRVBdwlb4R2V8mpdCQCmvomm .z0jN8z64o3pi3atwFzzSJ0Na.QqTiO.n.JaMJCCFQGgPehvPVhrP6MUK6h5tqCXSpjuskqUHk5Z f3zFNfdlzuYRHUonjg3S4VLgZ_xUvsBmxgGhK6NzKwIvpaGkRZfc5fSuokhv2ahPcEeLi9DfM38q 5Tcsrd3dh.Q-- In-reply-to: <20180227130248.GA10630@cventin.lip.ens-lyon.fr> From: Oliver Kiddle References: <20180207223051.GA30393@chaz.gmail.com> <4253.1518045946@thecus.kiddle.eu> <1518093995.645366.1263935336.265ED7BF@webmail.messagingengine.com> <17756.1518799875@thecus.kiddle.eu> <20180227130248.GA10630@cventin.lip.ens-lyon.fr> To: zsh-workers@zsh.org Subject: Re: inf and nan in arithmetic expansions MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12827.1519745147.1@thecus.kiddle.eu> Date: Tue, 27 Feb 2018 16:25:47 +0100 Message-ID: <12828.1519745147@thecus.kiddle.eu> Vincent Lefevre wrote: > > This is actually system specific. We generate whatever printf(3) > > generates. Try out Stephane's examples on Solaris and you get Inf and > > NaN instead. I think I prefer those forms. We can make the printf code > > detect them and hard code a consistent form so that we are consistent > > across platforms. > > What do you mean by "We generate whatever printf(3) generates."? Zsh calls printf(3) to do the work underneath. The following code: #include int main() { printf("%g\n", 1e9999); } Will output "Inf" on Solaris and "inf" on Linux (for glibc at least). And the zsh printf builtin does likewise on each platform. > On Debian/unstable: > > cventin% echo $((1e9999)) > inf. That trailing . is unrelated. It is added to ensure floating point types remain floating point which is not applicable to Inf and NaN. > cventin% printf "%g\n" 1e9999 > cventin% /usr/bin/printf "%g\n" 1e9999 How 1e9999 is interpreted a different matter. Zsh first tries strtod() then full zsh math evaluation. So printf "%g\n" 3+4 works in zsh but not coreutils' printf. I do intend to get the patch cleaned up and a follow-up submitted but it has been a busy time. Oliver