Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Floating point modulus
On Sun, 11 Jan 2015 11:36:01 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author