On Wednesday, 19 February 2003 at 9:22:18 -0800, Wes Peters wrote:
> On Tuesday 18 February 2003 22:36, Peter Jeremy wrote:
>>
>> I see this as a major advantage of arc4random() - if I want 32-bit
>> random numbers I don't have to call random() twice and merge the
>> results. I've never understoo
Hi,
At 17:27 19/2/03, Tim Kientzle wrote:
Dag-Erling Smorgrav wrote:
[EMAIL PROTECTED] writes:
Well, I'm right in principle but wrong in current practice, at
the very least make it:
#define arc4random31() (arc4random() & RAND_MAX)
or rather
#define arc4random31() (arc4random() % (RAND_M
On Tuesday 18 February 2003 22:36, Peter Jeremy wrote:
>
> I see this as a major advantage of arc4random() - if I want 32-bit
> random numbers I don't have to call random() twice and merge the
> results. I've never understood why random() was specified to return
> a '0' in the MSB.
It probably ha
Dag-Erling Smorgrav wrote:
[EMAIL PROTECTED] writes:
Well, I'm right in principle but wrong in current practice, at
the very least make it:
#define arc4random31() (arc4random() & RAND_MAX)
or rather
#define arc4random31() (arc4random() % (RAND_MAX + 1))
to avoid relying on RAND_MAX be
Peter Jeremy <[EMAIL PROTECTED]> writes:
> In any case, doesn't the name imply that it's 31-bits...
Yes, it's a bad name.
DES
--
Dag-Erling Smorgrav - [EMAIL PROTECTED]
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message
[EMAIL PROTECTED] writes:
> Well, I'm right in principle but wrong in current practice, at
> the very least make it:
>
> #define arc4random31() (arc4random() & RAND_MAX)
or rather
#define arc4random31() (arc4random() % (RAND_MAX + 1))
to avoid relying on RAND_MAX being one less than a power
Thus spake Paul Herman <[EMAIL PROTECTED]>:
> On Wed, 19 Feb 2003 [EMAIL PROTECTED] wrote:
>
> > In message <[EMAIL PROTECTED]>, Paul Herma
> > n writes:
> >
> > > arc4random() returns random numbers in the range of 0 to
> > > (2**32)-1, and therefore has twice the range of RAND_MAX.
> >
> > Goo
In message <[EMAIL PROTECTED]>, Paul Herma
n writes:
>>
>> > EXAMPLES
>> > The following produces a drop-in replacement for the traditional
>> > random() and rand() functions using arc4random():
>> > #define arc4random31() (arc4random() & 0x7FFF)
>>
>> Not good. Only true on 32 bit a
On Wed, 19 Feb 2003 [EMAIL PROTECTED] wrote:
> In message <[EMAIL PROTECTED]>, Paul Herma
> n writes:
>
> > arc4random() returns random numbers in the range of 0 to
> > (2**32)-1, and therefore has twice the range of RAND_MAX.
>
> Good.
>
> > EXAMPLES
> > The following produces a drop-in repla
In message <[EMAIL PROTECTED]>, Paul Herma
n writes:
> arc4random() returns random numbers in the range of 0 to
> (2**32)-1, and therefore has twice the range of RAND_MAX.
Good.
> EXAMPLES
> The following produces a drop-in replacement for the traditional
> random() and rand() functions usi
On Wed, 19 Feb 2003, Peter Jeremy wrote:
> On Tue, Feb 18, 2003 at 06:22:37PM -0800, Paul Herman wrote:
> >
> > [...range of arc4random() is twice that of random()...]
>
> I see this as a major advantage of arc4random()
I see this as an advantage, too. It's also produces random numbers
with a ver
On Tue, Feb 18, 2003 at 06:22:37PM -0800, Paul Herman wrote:
>On Tue, 18 Feb 2003, Anthony Schneider wrote:
>
>> an issue of arc4random return u_int32_t and rand*
>> returning int (ie unsigned vs signed)?
>
>Nope, casting arc4random() to int or casting random() to unsigned
>int won't solve the prob
On Tue, 18 Feb 2003, Anthony Schneider wrote:
> an issue of arc4random return u_int32_t and rand*
> returning int (ie unsigned vs signed)?
Nope, casting arc4random() to int or casting random() to unsigned
int won't solve the problem. The problem still is that
arc4random()'s range is twice that o
an issue of arc4random return u_int32_t and rand*
returning int (ie unsigned vs signed)?
-Anthony.
On Tue, Feb 18, 2003 at 04:04:57PM -0800, Paul Herman wrote:
> Hi,
>
> ...a potential quick commit for someone. :-)
>
> What's the concesus that arc4random() should be a drop-in
> replacement for
On Tue, Feb 18, 2003 at 04:04:57PM -0800, Paul Herman wrote:
> What's the concesus that arc4random() should be a drop-in
> replacement for rand()/random()? Consider the following that
> caclulates the average of a bunch of random numbers on [0.0, 1.0]:
rand() and random() return signed values (i
Hi,
...a potential quick commit for someone. :-)
What's the concesus that arc4random() should be a drop-in
replacement for rand()/random()? Consider the following that
caclulates the average of a bunch of random numbers on [0.0, 1.0]:
bash$ cat rand.c
#include
int i;
double avg;
#d
16 matches
Mail list logo