GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
rand1.c
Go to the documentation of this file.
1 #include <grass/config.h>
2 #include <stdlib.h>
3 #include <grass/gmath.h>
4 
5 
17 float G_math_rand(int seed)
18 {
19 #if defined(HAVE_DRAND48)
20  if (seed < 0)
21  srand48(-seed);
22 
23  return (float)drand48();
24 #else
25  if (seed < 0)
26  srand(-seed);
27 
28  return 1.0f * rand() / RAND_MAX;
29 #endif
30 }
float G_math_rand(int seed)
Random Number Generator (Uniform)
Definition: rand1.c:17