From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17428 invoked by alias); 12 Jan 2015 02:46:52 -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: 34247 Received: (qmail 20603 invoked from network); 12 Jan 2015 02:46:50 -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=e42AR5L2LgpmXhsdKTEA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150111184632.ZM3188@torch.brasslantern.com> Date: Sun, 11 Jan 2015 18:46:32 -0800 In-reply-to: <20150111202538.4859dbe0@ntlworld.com> Comments: In reply to Peter Stephenson "Re: Floating point modulus" (Jan 11, 8:25pm) References: <1420807419-9270-1-git-send-email-mikachu@gmail.com> <54B013C5.6090307@eastlink.ca> <54B04A7A.1010402@eastlink.ca> <20150109223028.6e003bff@ntlworld.com> <54B066C5.3010008@eastlink.ca> <54B0D893.4080202@eastlink.ca> <510FB8E2-EA0C-4582-BD31-527E9755F0FB@larryv.me> <54B1ACA3.1050001@eastlink.ca> <150110175849.ZM21774@torch.brasslantern.com> <54B20E23.8090900@eastlink.ca> <150110231017.ZM24021@torch.brasslantern.com> <150111113601.ZM29941@torch.brasslantern.com> <20150111200119.134bfe2d@ntlworld.com> <150111120423.ZM10129@torch.brasslantern.com> <20150111202538.4859dbe0@ntlworld.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Subject: Re: Floating point modulus MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 11, 8:25pm, Peter Stephenson wrote: } } I'll leave that to you, but instead of an explicit rounding you could do } basically the same calculation but assigned to a variable declared as an } integer and output that. Hm. This seems like a bug: % integer rnd % print -- $(( rnd = ((29.1 % 13.0 * 10) + 0.5) )) 31.500000000000014 Shouldn't the result of the $(( ... )) be an integer because rnd has been declared as an integer? I had to do this instead: diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst index 59d182a..8da17f7 100644 --- a/Test/C01arith.ztst +++ b/Test/C01arith.ztst @@ -18,6 +18,12 @@ 0:basic floating point arithmetic >31415. + integer rnd + (( rnd = ((29.1 % 13.0 * 10) + 0.5) )) + print $rnd +0:Test floating point modulo function +>31 + print $(( 0x10 + 0X01 + 2#1010 )) 0:base input >27 -- Barton E. Schaefer