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 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: pgp00584.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