diff options
-rw-r--r-- | src/new.c | 10 | ||||
-rw-r--r-- | src/new32.c | 10 | ||||
-rw-r--r-- | src/new32v2.c | 2 |
3 files changed, 11 insertions, 11 deletions
@@ -9,16 +9,16 @@ static const uint64_t divtab[244] = { [243] = 0x010db20a + 1l }; -#define FASTDIV(n, C) (((n) * (C)) >> 32) -#define FASTMOD(n, d, C) ((n) - (d) * FASTDIV((n), (C))) +#define FASTDIV(n, d) (((n) * divtab[d]) >> 32) +#define FASTMOD(n, d) ((n) - (d) * FASTDIV((n), (d))) int new(int i, int x, int y) { uint64_t A, B, C; - A = FASTDIV(i, divtab[y]); - B = FASTMOD(A, 3, divtab[3]); - C = FASTMOD(A + (uint64_t)x, 3, divtab[3]); + A = FASTDIV(i, y); + B = FASTMOD(A, 3); + C = FASTMOD(A + (uint64_t)x, 3); return i + (C - B) * y; } diff --git a/src/new32.c b/src/new32.c index 9136115..654b793 100644 --- a/src/new32.c +++ b/src/new32.c @@ -9,16 +9,16 @@ static const unsigned int divtab[244] = { [243] = 0x010d + 1l }; -#define FASTDIV(n, C) (((n) * (C)) >> 16) -#define FASTMOD(n, d, C) ((n) - (d) * FASTDIV((n), (C))) +#define FASTDIV(n, d) (((n) * divtab[d]) >> 16) +#define FASTMOD(n, d) ((n) - (d) * FASTDIV((n), (d))) int new32(int i, int x, int y) { int A, B, C; - A = FASTDIV(i, divtab[y]); - B = FASTMOD(A, 3, divtab[3]); - C = FASTMOD(A + x, 3, divtab[3]); + A = FASTDIV(i, y); + B = FASTMOD(A, 3); + C = FASTMOD(A + x, 3); return i + (C - B) * y; } diff --git a/src/new32v2.c b/src/new32v2.c index a755d6d..1fd4c6f 100644 --- a/src/new32v2.c +++ b/src/new32v2.c @@ -9,7 +9,7 @@ static const unsigned int divtab[244] = { [243] = 0x010d + 1l }; -#define FASTDIV(n, d) (((n) * (divtab[d])) >> 16) +#define FASTDIV(n, d) (((n) * divtab[d]) >> 16) int new32v2(int i, int x, int y) { |