Skip to content

Instantly share code, notes, and snippets.

@warm-ice0x00
Created February 14, 2024 19:56
Show Gist options
  • Save warm-ice0x00/2ac71cb2bd0bedef6d3082f3aba973bf to your computer and use it in GitHub Desktop.
Save warm-ice0x00/2ac71cb2bd0bedef6d3082f3aba973bf to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <time.h>
unsigned long Rand(const unsigned long x) {
return ((x << 16) + (x << 1) + x) & 0x7FFFFFFF;
}
unsigned long RandInt(const unsigned long x, const unsigned long a,
const unsigned long b) {
return a + x / (0x7FFFFFFF / (b - a + 1) + 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment