[Click] random
Eddie Kohler
kohler at cs.ucla.edu
Tue Aug 7 09:51:20 EDT 2007
Jean-Sebastien,
(1) If you are planning to run your element in the kernel, then you cannot use
C's "double" or "float" types. These types should never be used in the kernel.
(2) If you are running at user level, you can call drand48() to get a random
number between 0 and 1 (including 0, excluding 1). This is a C standard
library function.
(3) Or you can say "(double) random() / (RAND_MAX + 1)" to get a double random
number between 0 and 1.
Eddie
JS wrote:
> Hi everyone,
> sorry to bother you again but I am still fighting to understand how the
> random function works in Click...
> I need to pick a random number between 0 and 1 and the only thing I have
> found about random at this time is in the RED element where they are using
> _random_value = (random() >> 5) & 0xFFFF;
> I guess this is a bit operation but I don't know what number is coming out
> of the random() function.
> So if anyone knows how to generate a number between 0 and 1 it would help me
> a lot.
> Regards
> Jean-Sebastien
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
More information about the click
mailing list