Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package net.devtech;
  2.  
  3.  
  4. /**
  5. * static splittable random
  6. */
  7. public class Rand {
  8. private static final long GOLDEN_GAMMA = 0x9e3779b97f4a7c15L;
  9. private Rand() {/*static class*/}
  10.  
  11. public static int next(long[] seed) {
  12. long z = seed[0] += GOLDEN_GAMMA;
  13. z = (z ^ (z >>> 33)) * 0x62a9d9ed799705f5L;
  14. return (int) (((z ^ (z >>> 28)) * 0xcb24d0a5c88c35b3L) >>> 32);
  15. }
  16.  
  17. public static int next(long seed) {
  18. long z = seed + GOLDEN_GAMMA;
  19. z = (z ^ (z >>> 33)) * 0x62a9d9ed799705f5L;
  20. return (int) (((z ^ (z >>> 28)) * 0xcb24d0a5c88c35b3L) >>> 32);
  21. }
  22.  
  23.  
  24. public static long seed(int x, int y) {
  25. return (long) x << 32 | y & 0xFFFFFFFFL;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement