slang-users mailing list

[2008 Date Index] [2008 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] generating random characters


> 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]