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 #define epsilon 0.0001
00009 
00010 u8 within_epsilon(double a, double b) {
00011   if (fabs(a - b) < epsilon) {
00012     return 1;
00013   }
00014   return 0;
00015 }
00016 
00017 void seed_rng(void) {
00018   srandom(time(NULL));
00019 }
00020 
00021 double frand(double fmin, double fmax) {
00022   double f = (double)random() / RAND_MAX;
00023   return fmin + f * (fmax - fmin);
00024 }
00025 
00026 u32 sizerand(u32 sizemax) {
00027   double f = (double)random() / RAND_MAX;
00028   return (u32) ceil(f * sizemax);
00029 }


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:28