GRASS Programmer's Manual  6.4.2(2012)
rand1.c
Go to the documentation of this file.
00001 #include <grass/config.h>
00002 #include <stdlib.h>
00003 #include <grass/gmath.h>
00004 
00005 
00017 float G_math_rand(int seed)
00018 {
00019 #if defined(HAVE_DRAND48)
00020     if (seed < 0)
00021         srand48(-seed);
00022 
00023     return (float)drand48();
00024 #else
00025     if (seed < 0)
00026         srand(-seed);
00027 
00028     return 1.0f * rand() / RAND_MAX;
00029 #endif
00030 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines