fork download
  1. #include <iostream>
  2.  
  3. //This function returns the same result for given values but should be somewhat random.
  4. double PRH(unsigned iterations, int x, int y) {
  5. unsigned long long hash;
  6. x &= 0xFFF;
  7. y &= 0xFFF;
  8. iterations &= 0xFF;
  9. hash = (iterations << 24);
  10. hash |= (y << 12);
  11. hash |= x;
  12. unsigned long long rem = hash & 3;
  13. unsigned long long h = hash;
  14.  
  15. switch (rem) {
  16. case 3:
  17. hash += h;
  18. hash ^= hash << 32;
  19. hash ^= h << 36;
  20. hash += hash >> 22;
  21. break;
  22. case 2:
  23. hash += h;
  24. hash ^= hash << 22;
  25. hash += hash >> 34;
  26. break;
  27. case 1:
  28. hash += h;
  29. hash ^= hash << 20;
  30. hash += hash >> 2;
  31. }
  32. hash ^= hash << 6;
  33. hash += hash >> 10;
  34. hash ^= hash << 8;
  35. hash += hash >> 34;
  36. hash ^= hash << 50;
  37. hash += hash >> 12;
  38.  
  39. return (hash & 0xFFFF) / static_cast<double>(0xFFFF);
  40. }
  41.  
  42. int main()
  43. {
  44. std::cout << PRH(25, 6, 7);
  45. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
0.17406