Skip to content

Instantly share code, notes, and snippets.

@fujidig
Created January 4, 2016 22:34
Show Gist options
  • Select an option

  • Save fujidig/a4b914f46a75d99f2c11 to your computer and use it in GitHub Desktop.

Select an option

Save fujidig/a4b914f46a75d99f2c11 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <inttypes.h>
uint32_t seed = 0;
double rand() {
seed = seed * 1103515245 + 12345;
return (double)seed / 4294967296.0;
}
int main() {
uint32_t i = 0;
do {
if ((i & 0xfffff) == 0) {
fprintf(stderr, "%08x\n", i);
}
double x, y, z;
x = rand(); y = rand(); z = rand();
if (x < 0.01 && y < 0.01 && z < 0.01) {
printf("%f\t%f\t%f\n", x, y, z);
}
i ++;
} while (i != 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment