# Are there any hash functions/stateless RNGs that do not use XOR, but produce good quality visual randomness?

I'm looking for a small function from integers to integers - in a language that only has floats - that can act as a visual RNG. Normally I would use a function such as the one described here:

int cash(int x, int y){
int h = seed + x*374761393 + y*668265263; //all constants are prime
h = (h^(h >> 13))*1274126177;
return h^(h >> 16);
}


However, for the thing I'm working on, I have the added restriction of only using arithmetic operations. the operations I have available are: +, *, -, /, %, sign(), abs(), pow(base, exponent), ln(), floor(), as well as basic trig functions. I'm having difficulty finding anything that doesn't rely on having bitwise operations available. Does anyone know of a hash function that doesn't use xor, that produces reasonable visual randomness when fed a linear sequence of integers?

• Which are you looking for? A hash function, or a pseudorandom number generator? The answer will probably be different. Note that you can similar integer arithmetic using floats, as long as the integers don't get too large (i.e., as long as the floats have enough precision), or by using big-int methods. You can implement xor by converting the integer to its binary representation and then xor-ing bitwise. There are some schemes that use array lookups and/or right/left shifts. The challenge with using floats is that the resulting scheme might not be deterministic/reproducible.
– D.W.
Jul 30 '17 at 23:02
• I want a PRNG that takes a seed and no further information: aka, a hash function. I'm not using a language that has integers, or operations on them. xor just doesn't exist at all. I also can't do array lookups - it has to be 1. purely functional and 2. just arithmetic operations. the reason I want this is a bit silly, it's a code-golf type of thing. that's why I'm so limited, though - it really does have to only use the operations I mentioned. Jul 31 '17 at 1:51
• If you have booleans, you can build integer arithmetic (and xor) out of that. If you have floats, you can express booleans. It's all Turing-complete. I realize that doesn't answer your question exactly.
– D.W.
Jul 31 '17 at 6:09
• yeah, I understand that, but that would take a lot of hacking - it's actually not Turing complete, I have to add more code to get more compute depth. I was hoping there would be a known function that only takes on the order of 30 operations - an implementation of binary operations would take far more. Jul 31 '17 at 15:07

float rand(vec2 co){

or as I implemented it: $\operatorname{mod}\left(\sin \left(a\cdot 12.9898+b\cdot 78.233\right)\cdot 43758.5453,\ 1\right)$