From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7147 invoked from network); 25 Mar 2021 01:37:18 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Mar 2021 01:37:18 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1616636238; b=FVwECFZhL0wHZkJ9aRUtEuqQTx4dQnQ9VcFRvxQt3jnT59dA7xSEkBsvchsZk0yekftc8TpXKe 6EdnzmC8iqttIl42ZzMoAk05IWi2MW/A8nv7+ivZYig845dNxNRubVbIufW8PFdRzQbRtrBFSP 7dPiz0DOngDjMqD3rLu6vabySYTbPM0ymmuuUaZFqxF5fP9OWtUPU62NmGh6IlmJWebMMEH/We e48t7j1vmlZUufU8vjo4E5AtwfxgKwjpkCeuuyNUeGvWtQ9OFo2xXP5pB6F3Sl80o6l6GIzkPV KLG1J3oZKsMfYtEEMPBRbZD0OweTreeUdy7jcAUxhtlDcw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout3-smtp.messagingengine.com) smtp.remote-ip=64.147.123.19; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1616636238; bh=X9Oh2kzTUgEl+iqbGZj03xxGFlceVHHyS3F/MfvMY7M=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=q8sJ2TpJ5qkTye4yg6cQypS2Ix3VznUF1fWnBJS+sTdKXm5PyAbdvZsK86X+I26VXE1NbIUjbw /qYG45PlU60ElP9G9l19xyuFs6rSs/lx5gb/8ptfTiecQrw6NdxtDyRz9kZ/oxJ6QTP7NN31HN a87Excb4TfxX0sjXfleueVo8J2qRY1wh2A/MnW7VAZc03/n6Wxr9xZENTsx/Z91MsZl+dN6QKv Dz/f/lMAkcMkCTwilQ3AKsniz4tAlwKkmYzJCksHTvovfAEsvviAXIoXAULiRQyadbhl/rvCIo +kTV4WGyN8Rkd6maSu+NUlFNbAHWHXdrhIZMRVMId6zG0w==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=X8FPl3/FzuBMlupWkFmIMsAiT0FK5bxxZQfjci0slcY=; b=ztCLiNSkqEgEy1MbPk+i4cxbus 27sarpSGZ59TckbYQMuHQmtwXyVKZJC0ykYjqQZG8CqIbCm8+fVz8FRnRgg4bySOnzXNBM09oRRKW Izkv5ORmicNiDK5Dp6FsFzf0MAHig7aY5u4K6WIy+X1WTBnn9WRi/c5oKYO0zdDUdmqS9CP7W8sxL wAC0jMEP9Q9pPfYGkN9A/odRVl9YOn6RxRqypNVMvAas9tf7ziFosQz9CdwpzfYJ8wBwP6bqNULjF QgBUglGSRhf3Sn90RfzovOdUk0/qRT+oeYwKs2uRfGX2opCl2CJfbYyT4fPXZMN5aMMtyMUE9b8YF 2Ns910gQ==; Received: from authenticated user by zero.zsh.org with local id 1lPEw1-000GDp-0g; Thu, 25 Mar 2021 01:37:17 +0000 Authentication-Results: zsh.org; iprev=pass (wout3-smtp.messagingengine.com) smtp.remote-ip=64.147.123.19; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:40265) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lPEvW-000FrM-Jr; Thu, 25 Mar 2021 01:36:47 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id CD1F6FA4; Wed, 24 Mar 2021 21:36:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 24 Mar 2021 21:36:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:subject:message-id:references :mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm2; bh=X8FPl3/FzuBMlupWkFmIMsAiT0FK5bxxZQfjci0s lcY=; b=azbqR6pwhzOrQ/zNjltEsn9PdC62wpIOQ8wbh0K8R8J86IplhdtWryW8 e58olie/P2LTNISlyX1jscw5ZHnQIg8JDnTWzVuwYycM9mzQuSbQpLFKEv0jAu2d ALgDhy8mWO1CFSxOUe3V4xDRY6i3lPPMDoeA8r75qCKQ0vNSaf5aohFgnStcHBrU Hs5QxzcC3m9qMflI/86Q531J7nIBDElyL2dNCvrAgO6a0l2X4yXNNhuXanVt6pyO lCvcHVuS+eYlj96QdtWdMtkeebui0jVP44PBh4A6L8EYM4twr6NNlceTyNl/p/An BUAPj4kfxeLwPLvK0rpA91o1n3FNXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=X8FPl3/FzuBMlupWkFmIMsAiT0FK5bxxZQfjci0sl cY=; b=ZTtRPrzXVNM7QIOV7zRWWfWORRiiRe0aeMPp8XSCRHzjfCueQJi+/9FkB nrNWMPxogACjthoy6QC8VrI2JJvfJ9czsq+9vpo3BGzi12Qftve5tTByPVnO55wh 8h/t4Jop5I0TTdUMQ1cZY8ycFWLRIFjcyTaTbrvPNhDexQtuLOrwK6SJCDC9qtTr A49lpXimfo0R5KMFwTPEbqrF6P+J8crR+JmezviEpimbEcnYMw9LCIO5iCAzoRSN zYClKHBRzRSaFvV6vv3BFqnO3BvUZOp/v6gZsP7NI61j6KA6cJzrPM6nWbB09Y9V uCUaRXvzaDuw+shRSepfHK0aGecUA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegledgfeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggugfgjfgesth ektddttderjeenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghn ihgvlhdrshhhrghhrghfrdhnrghmvgeqnecuggftrfgrthhtvghrnhepgfekgfefjefgvd dvgfdutdelleekvdefteeitdduhfevveevudfhvdevfeefvdeunecukfhppeejledrudek vddrfeeirddukedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-79-182-36-181.red.bezeqint.net [79.182.36.181]) by mail.messagingengine.com (Postfix) with ESMTPA id F0A9E108005C for ; Wed, 24 Mar 2021 21:36:43 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4F5SPj6qrHzwp; Thu, 25 Mar 2021 01:36:41 +0000 (UTC) Date: Thu, 25 Mar 2021 01:36:41 +0000 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Re: forcing float arithmetic. Message-ID: <20210325013641.GE18178@tarpaulin.shahaf.local2> References: <22260ea8-adec-6e16-9250-c2c2ab31fcba@eastlink.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <22260ea8-adec-6e16-9250-c2c2ab31fcba@eastlink.ca> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 26596 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Ray Andrews wrote on Wed, Mar 24, 2021 at 18:12:29 -0700: > On 2021-03-24 2:59 p.m., Bart Schaefer wrote: > > On Wed, Mar 24, 2021 at 2:54 PM Roman Perepelitsa > > wrote: > > > The behavior of zsh in this regard is consistent with C and all languages inspired by it (C++, Java, C# and many, many others). This is really working as intended. > > Proof: > > > > #include > > void main() { > > int x = 3, y = 7; > > float z = (x/y); > > printf("%g\n", z); > > } > > > Long time since I did any floating point in C, so I'll take you guy's word > for it.  Final shot would that since one can force the conversion by, say, > multiplying by 1.0, which is otherwise pointless, one could imagine some > option whereby the bother is simply not required. > > (( aa = ((2 * nn) - 1) / (nn**2.0) )) > > ... in that case the denominator is not changed in any way, yet if flags > that the division should be passed as a float.  Seems an awkward way of > getting the conversion.  How is 2^2 different from 2^2.0 ?  If 'aa' was an > integer then of course the result must be rounded, but it still seems to me > the float should receive the actual result. The «/» operator is defined to perform integer division (discarding the remainder) when both of its arguments are integers, and floating-point division otherwise. That _is_ inconsistent, in a way, since in C it's not possible to implement a two-argument function that has the same semantics as the «/» operator for both integral and floating-point types… but that's how it is. > One of my little whines, nothing of substance. Still one might dream > of setopt AUTO_FLOAT. Python 3's division operator always returns floats. Daniel