X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Fyarandom.h;h=eb560a2fd04256a614d5cb30c0fde7cdffd6ff14;hb=6a1da724858673ac40aa13a9612340d8bed8c7b9;hp=14a287fa8c04ef432086bc3768ac8d2dde6ad0f7;hpb=4cecfc89e5e889c7232693897c06168fb378bd5c;p=xscreensaver diff --git a/utils/yarandom.h b/utils/yarandom.h index 14a287fa..eb560a2f 100644 --- a/utils/yarandom.h +++ b/utils/yarandom.h @@ -47,16 +47,17 @@ extern void ya_rand_init (unsigned int); /* Implement frand using GCC's statement-expression extension. */ # define frand(f) \ - ({ double tmp = (((double) random()) / \ - (((double) ((unsigned int)~0)) / ((double) (f)))); \ + __extension__ \ + ({ double tmp = ((((double) random()) * ((double) (f))) / \ + ((double) ((unsigned int)~0))); \ tmp < 0 ? (-tmp) : tmp; }) #else /* not GCC2 - implement frand using a global variable.*/ static double _frand_tmp_; # define frand(f) \ - (_frand_tmp_ = (((double) random()) / \ - (((double) ((unsigned int)~0)) / ((double) (f)))), \ + (_frand_tmp_ = ((((double) random()) * ((double) (f))) / \ + ((double) ((unsigned int)~0))), \ _frand_tmp_ < 0 ? (-_frand_tmp_) : _frand_tmp_) #endif /* not GCC2 */