check_utils.c
Go to the documentation of this file.
00001 #include <time.h>
00002 #include <stdlib.h>
00003 #include <stdio.h>
00004 #include <math.h>
00005 
00006 #include "check_utils.h"
00007 
00008 void seed_rng(void) {
00009   FILE* fp = fopen("/dev/urandom", "r");
00010   unsigned int seed;
00011   int out;
00012   if ((out = fread(&seed, sizeof(seed), 1, fp)) == sizeof(seed))
00013     srandom(seed);
00014 }
00015 
00016 double frand(double fmin, double fmax) {
00017   double f = (double)random() / RAND_MAX;
00018   return fmin + f * (fmax - fmin);
00019 }
00020 
00021 u32 sizerand(u32 sizemax) {
00022   double f = (double)random() / RAND_MAX;
00023   return (u32) ceil(f * sizemax);
00024 }


enu
Author(s): Mike Purvis
autogenerated on Fri Jan 3 2014 11:21:07