On Jul 2, 10:04 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> howa wrote:
> > On 7月2日, 下午11時59分, [EMAIL PROTECTED] (John W. Krahn) wrote:
> >> howa wrote:
> >>> Hi,
> >> Hello,
>
> >>> I want to have a max range of rand function, so I use
> >>> my $rnd = rand(4294967295) ;
> >>> However, is it safe to use so, e.g. in 32 bit system?
> >> rand() returns a floating point number that is based on RANDBITS and not
> >> the size of the CPU registers, so to see how many bits rand() uses run
> >> this on the command line:
>
> > But what should be the max. input to the rand() function and how
> > large it can return?
>
> It depends on how many RANDBITS your version of Perl supports.
>
> > Since I assign to $rnd as the result, then it must be stored as an
> > integer.
>
> No.
>
> perldoc -f rand
> [snip]
>          Apply "int()" to the value returned by "rand()" if you want
>          random integers instead of random fractional numbers.
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order.                            -- Larry Wall

I enjoy leaving the fractional part (mantissa?) on there as a 'bump'
when arbitrary ordering operations follow.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to