From: Vitaly V. B. <vit...@us...> - 2004-10-01 20:12:02
|
On Fri, 01 Oct 2004 12:25:37 +0200 Burkhard Plaum <pl...@ip...> wrote: > Dennis Smit wrote: > > > (which also includes a > > good pseudo random number gen, and while we add it, some nice range, > > float random features. > > An EXTREMELY useful function would be something like > > int lv_random_decide(float p); > > which returns 1 with a propability of p (0.0 <= p <= 1.0) :) Nice idea. int lv_random_decide(float a) { float x=(float)random()/RAND_MAX; return x <= a; } -- Vitaly GPG Key ID: F95A23B9 |