Fix warning.

WRAP is only safe for the int range, since it needs to cast to int to
negate; so only allow int.

When possible, use a (possibly templated) inline function instead of
a #define.
This commit is contained in:
Glenn Maynard
2003-09-01 02:04:16 +00:00
parent 985a040f49
commit 5b17149520
2 changed files with 11 additions and 4 deletions
+8 -1
View File
@@ -58,7 +58,14 @@ inline unsigned long max(unsigned long a, unsigned int b) { return a > b? a:b; }
#define CLAMP(x, l, h) {if (x > h) x = h; else if (x < l) x = l;}
#define WRAP(x, n) {if (x<0) x += ((-x/n)+1)*n; x = x%n;}
inline void wrap( int &x, int n)
{
if (x<0)
x += ((-x/n)+1)*n;
x %= n;
}
//-----------------------------------------------------------------------------