THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/06/2010 at 10:04, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Anything wrong with the C++ operator?
Kabe
Nothing wrong, in fact LModulo just wraps % with a special condition if a<0.
from c4d_tools.h
inline Real Modulo(Real a, Real b)
{
if (b==0.0) return 0.0;
LONG n = (LONG) (a/b);
a -= n*b;
if (a<0.0) a+= b;
return a;
}
inline LONG LModulo(LONG a, LONG b)
{
if (!b) return 0;
if (a >= 0) return a%b;
a -= (a/b)*b;
if (a<0) a+= b;
return a;
}
inline LLONG LModulo(LLONG a, LLONG b)
{
if (!b) return 0;
if (a >= 0) return a%b;
a -= (a/b)*b;
if (a<0) a+= b;
return a;
}
cheers,
Matthias