[Gridflow-cvs] [svn] commit: r3761 - /trunk/gridflow.h

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Tue Jun 3 16:44:51 EDT 2008


Author: matju
Date: Tue Jun  3 16:44:51 2008
New Revision: 3761

Log:
fix the modulo function (reverting back to old version)

Modified:
    trunk/gridflow.h

Modified: trunk/gridflow.h
==============================================================================
--- trunk/gridflow.h (original)
+++ trunk/gridflow.h Tue Jun  3 16:44:51 2008
@@ -73,7 +73,7 @@
 // a remainder function such that div2(a,b)*b+mod(a,b) = a and for which mod(a,b) is in [0;b) or (b;0].
 // in contrast to C-language builtin a%b, this one has uniform behaviour around zero,
 // that is, the same as around any other whole number.
-static inline int mod(int a, int b) {return a<0 ? b-((-a)%b) : a%b;}
+static inline int mod(int a, int b) {int c=a%b; c+=b&-(c&&(a<0)^(b<0)); return c;}
 
 // counterpart of mod(a,b), just like a/b and a%b are counterparts
 static inline int div2(int a, int b) {return (a/b)-((a<0)&&!!(a%b));}



More information about the Gridflow-cvs mailing list