From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21658 invoked by alias); 13 Jan 2015 10:10:31 -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: X-Seq: 34265 Received: (qmail 15906 invoked from network); 13 Jan 2015 10:10:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f4-b7f126d000001e9a-ff-54b4ef108aa6 Date: Tue, 13 Jan 2015 10:10:16 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Floating point modulus - the "why not" Message-id: <20150113101016.05d6c2a8@pwslap01u.europe.root.pri> In-reply-to: <150112213852.ZM19384@torch.brasslantern.com> References: <150112213852.ZM19384@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKLMWRmVeSWpSXmKPExsVy+t/xy7oC77eEGBzYKm1xsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4MrZ+2MBaMJul4uXuvSwNjNOZuxg5OSQETCT2vzzGCGGLSVy4 t56ti5GLQ0hgKaPEqr3zoZwlTBLfv2yDcrYxSnx7cokVpIVFQFXiaeMlNhCbTcBQYuqm2WCj RATEJc6uPc/SxcjBISxgLPH3cB5ImFfAXuLzitvsIDangJXE5tUNYFcICVhKLLp7FqyVX0Bf 4urfT0wQF9lLzLxyhhGiV1Dix+R7LCA2s4CWxOZtTawQtrzE5jVvoeaoS9y4u5t9AqPQLCQt s5C0zELSsoCReRWjaGppckFxUnquoV5xYm5xaV66XnJ+7iZGSNB+2cG4+JjVIUYBDkYlHt4d 2VtChFgTy4orcw8xSnAwK4nwzr8NFOJNSaysSi3Kjy8qzUktPsTIxMEp1cAo5nDkygyhEC/+ 2c5czBa7kpKXhSzx3D7tgYDMpyMT2SZaTYx6uZT9jOwJ2auCIbsFojYbZ5cccZtxcTOb+OwG fYUWng1Kq18n88xsSdy9NSGZRyMqv9NsrgTv5b7uhN7TU99m7RWq2c28/aPlsunrv5hmOGp8 rZ/61uZBjFvd6gc/Dkm42kgpsRRnJBpqMRcVJwIAWxHdFjgCAAA= On Mon, 12 Jan 2015 21:38:52 -0800 Bart Schaefer wrote: > I think we did the right thing, but just as a counter-point: > > torch% print $(( 91 % 13 )) > 0 > torch% print $(( 9.1 % 1.3 )) > 1.2999999999999994 That's the same problem with floating point division as everywhere else; if you need to round it, you need to decide what you're rounding to and add half of that before you truncate downwards. I don't think that's a fundamentally new effect in this one case. pws