Re: float and random number generator

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

 






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 ?
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 ?
Any suggestions are welcome.

thanks
Amit




Sven Schuster <schuster.sven@gmx.de> on 06/07/2004 06:17:12 PM

To:    Amit Kumar Singh/HSS@HSS
cc:    kernelnewbies@nl.linux.org

Subject:    Re: float and random number generator



Hi Amit,

On Mon, Jun 07, 2004 at 05:11:08PM +0530, aksingh@hss.hns.com told us:
>
> Hi,
>
> 1)   can we use float in the kernel modules, i don't find any
> using it ?

try googling for this one, this has probably been discussed quite a
feq times before and also should be on som faqs. Unfortunately I don't
have a link at hand. Maybe someone else can shed more light on this??

> 2)   do we have any random number generator in the
> kernel ? anything that can be used by modules, looked at linux/random.h,
> but there wasnt any generic random number generator that generated a
random
> number between two limits say 1 .. n, where n might be any positive
integer
> .

Take a look at get_random_bytes() in drivers/char/random.c. Take one
random byte (or two if 255 < n < 65536) and make a modulo division (%)
to get the maximum number you need.


HTH

Sven

>
> thanks
> Amit
>

--
Linux zion 2.6.7-rc2 #2 Mon May 31 22:58:01 CEST 2004 i686 athlon i386
GNU/Linux
  14:43:00  up 6 days, 15:42,  3 users,  load average: 0.07, 0.03, 0.00

Attachment: C.DTF
Description: Binary data


[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