I need to generate a pseudo-random number based on 2 input values X and Y. Given the same X and Y values I need to get the same result. The result should be between 0 and 1 inclusive.
So far I have this:
const int a = 0x7fffffff / 48271;
const int b = 0x7fffffff % 48397;
float rand(int x, int y) {
float seed, result;
seed = x ^ ((y << 1) & 0x2AAAAAAA) ^ ((y >> 1) & 0x33333333);
result = 48353 * (seed % a) - b * (seed / a);
return (result);
}
It's giving me a result but not what I'm looking for. I've cobbled it together from random things I've seen on the net, so no idea if it's really any good.