[slang-users] generating random characters
Michael Noble
mnoble at space.mit.edu
Tue Feb 12 15:13:17 UTC 2008
> 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);
}
More information about the slang-users-l
mailing list