Can you specify a, b or c? Does C have a known range?
These are 32-bit integers! Go check this site
For example, here's how you get mod n% d, where d 1 โ s (1,2,4,8, ...)
int n = 137; // numerator int d = 32; // denom d will be one of: 1, 2, 4, 8, 16, 32, ... int m; // m will be n % d m = n & (d - 1);
There is a code for n% d, where d is 1 โ s - 1 (1, 3, 7, 15, 31, ...)
This will only help if c is small, as you said.
johnnycrash
source share