From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27163 invoked by alias); 13 Jan 2015 16:57:10 -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: 34269 Received: (qmail 20248 invoked from network); 13 Jan 2015 16:57:08 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=D9vw8UVm c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=YNv0rlydsVwA:10 a=-QFm88ahBsUxkvAMygsA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150113085704.ZM20240@torch.brasslantern.com> Date: Tue, 13 Jan 2015 08:57:04 -0800 In-reply-to: <20150113161848.GC12079@ypig.lip.ens-lyon.fr> Comments: In reply to Vincent Lefevre "Re: Floating point modulus - the "why not"" (Jan 13, 5:18pm) References: <150112213852.ZM19384@torch.brasslantern.com> <20150113101016.05d6c2a8@pwslap01u.europe.root.pri> <20150113161848.GC12079@ypig.lip.ens-lyon.fr> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Floating point modulus - the "why not" MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 13, 5:18pm, Vincent Lefevre wrote: } Subject: Re: Floating point modulus - the "why not" } } On 2015-01-13 10:10:16 +0000, Peter Stephenson wrote: } > On Mon, 12 Jan 2015 21:38:52 -0800 } > Bart Schaefer wrote: } > > torch% print $(( 9.1 % 1.3 )) } > > 1.2999999999999994 } } The problem actually comes from the decimal to binary conversions, Yes, I know; the point is that you can't guarantee a consistent result from floating-point division, and this is particularly significant for modulus because the error may be (almost) as large as the divisor; so it's easy to see why that operation may have been left unimplemented. (Compare division torch% print $(( 9.1 / 1.3 )) 6.9999999999999991 where the error is a tiny fraction of the result.)