doug moen doug at moens.org
Fri May 15 06:56:53 EDT 2015

```Be warned that if you are looking for the modulus function as it is
normally defined in mathematics
(eg, as defined here: http://mathworld.wolfram.com/Mod.html)
then a % m is only equal to a mod m when the arguments are non-negative.

0 % 3 == 0    0 mod 3 == 0
1 % 3 == 1    1 mod 3 == 1
2 % 3 == 2    2 mod 3 == 2
3 % 3 == 0    3 mod 3 == 0

If the first argument is negative, you won't get the expected result.

-1 % 3 == -1  -1 mod 3 == 2

You can define the mod function like this (with correct behaviour for
negative arguments):

function mod(a,m) = a - m*floor(a/m);

On 15 May 2015 at 02:43, Chow Loong Jin <hyperair at debian.org> wrote:

> On Fri, May 15, 2015 at 08:07:03AM +0200, Robert Bielik wrote:
> > Hi all,
> >
> > New to OpenSCAD, fantastic tool! However I miss a modulo operator, or
> have I
> > missed it ? :)
>
> You mean arithmetic modulo? That's %.
>
> --
> Kind regards,
> Loong Jin
>
> _______________________________________________