From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18930 invoked by alias); 11 Jan 2015 20:01:26 -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: 34239 Received: (qmail 18215 invoked from network); 11 Jan 2015 20:01:24 -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-Originating-IP: [86.6.153.127] X-Spam: 0 X-Authority: v=2.1 cv=AoZg3YNP c=1 sm=1 tr=0 a=39NrsSuza2clQiZR/7fYWQ==:117 a=39NrsSuza2clQiZR/7fYWQ==:17 a=kj9zAlcOel0A:10 a=NLZqzBF-AAAA:8 a=q2GGsy2AAAAA:8 a=1rBHqKh-j2bh-1pJUoEA:9 a=CjuIK1q_8ugA:10 Date: Sun, 11 Jan 2015 20:01:19 +0000 From: Peter Stephenson To: Subject: Re: Floating point modulus Message-ID: <20150111200119.134bfe2d@ntlworld.com> In-Reply-To: <150111113601.ZM29941@torch.brasslantern.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 11 Jan 2015 11:36:01 -0800 Bart Schaefer wrote: > On Jan 10, 11:10pm, Bart Schaefer wrote: > } The following patch would instead silently substitute the fmod() call > } when using the % operator on a float. > > Incidentally, what's a reliable test for this that could be added to > C01arith.ztst? I worry about rounding error differing by platform: > > torch% print $(( 29.1 % 13.0 )) > 3.1000000000000014 diff --git a/Test/V03mathfunc.ztst b/Test/V03mathfunc.ztst index ab383db..8761252 100644 --- a/Test/V03mathfunc.ztst +++ b/Test/V03mathfunc.ztst @@ -142,3 +142,7 @@ F:This test fails if your math library doesn't have erand48(). print $g, $l 0:Test Gamma function gamma and lgamma >1.00000, 0.00000 + + print $(( int((29.1 % 13.0 * 10) + 0.5) )) +0:Test floating point modulo function +>31 pws