- Subject: Re: [slang-users] generating random characters
- From: Michael Noble <mnoble@xxxxxxxxxxxxx>
- Date: Tue, 12 Feb 2008 10:13:17 -0500
> I was thinking as a workaround using the internal bash function
> $RANDOM which generates a random number between 0 and 32767.
Will all slrn users, e.g. those on Windows, have access to bash?
Below is a "random" number generator I've used in several projects,
stemming from the linear congruential method described in Knuth's
"The Art of Computer Programming," Vol 2, Section 3.2.1.
Hope This Helps,
Mike
---
private variable rseed = getpid();
private define random()
{
rseed = (rseed * 0x5DEECEDL + 0xB) & ((1 shl 30) - 1);
(rseed shr 6) / ((1 shl 24) * 1.0);
}
[2008 date index]
[2008 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]