Re: float and random number generator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Amit,

On Mon, Jun 07, 2004 at 06:53:57PM +0530, aksingh@hss.hns.com told us:
> 
> Hi
> 
> How about net_random() and net_srandom()(in net/core/utils.c), theyre also
> random number generators, any suggestions as to which is better
> get_random_bytes () or any of these ?

Well, after taking a short look at what net_random() and net_srandom()
do I'd say that get_random_bytes() does a better job (i.e. better
random values), at least it seems like to me. net_(s)random() take
net_rand_seed as a base, which is initialized to 152, do some 
multiplication and return net_rand_seed ^ jiffies, which results in
a monotonically increasing value (ok, there's of course an overflow
of net_rand_seed). But no more "real" randomness. OTOH, get_random_bytes()
gets it's random numbers from the entropy pool which should give you
better random numbers. Just my opinion, of course, maybe I have 
overlooked something.

> Thanks Sven, but would a & not be better than a % to get a value between 0
> and my max value, i.e i can do a (get_random_bytes_returned & max_value).
> Does this in anyway reduce randomnness ?

Both should basically be the same I think.


Sven

> Any suggestions are welcome.
> 
> thanks
> Amit
> 

-- 
Linux zion 2.6.7-rc2 #2 Mon May 31 22:58:01 CEST 2004 i686 athlon i386 GNU/Linux
 15:39:41  up 6 days, 16:39,  3 users,  load average: 0.00, 0.00, 0.00

Attachment: pgp00585.pgp
Description: PGP signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux