Can I use z%=RND(-1,0,1)?
Will this give me a 33.3...% chance of giving a random number?
Regards
Andy Barber
Mailto:[EMAIL PROTECTED]
Tel: +44 20 8402 3385 ~ Mobile +44 791 883 4739 ~ Fax: +44 705 069 5845
An equivalent method would be:
z% = RND(-1 to 1)
which would generate values of -1, 0, or 1, with roughly equal chances of it
throwing up any of the three values. Subject to the dreaded random number
generator, of course. Hope I understood what you meant, Andy.
Interestingly, as an aside, if you supply fixed RANDOMISE values beforehand,
IIRC it would generate the same sequence of random numbers.
100 INPUT integer_number%
110 RANDOMISE integer_number%
120 FOR a=1 TO 9:PRINT RND(0 TO 100)
Try entering the same number several times in line 100, you will, if I am
right, get the same series of 9 random numbers! Might form a kind of
encryption routine where you'd have to enter the correct key (the correct
parameter for RANDOMISE) to be able to decode it. Create a series of 26
"random" numbers using a given RANDOMISE value to encode the text, then that
table could only be reconstructed to decode the text at the other end if you
knew what value to use for the seed. There'd only be a 16-bit range of
values, so encryption wouldn't be too strong, but you could have fun playing
with it. Very logical things, QL "random" numbers :-)
Text encryption is of course possible by translating the text to a minority
language such as Welsh to render it unreadable to the majority, although you
can get web translation services for most languages nowadays, including
Welsh. I'm sure I've read somewhere about the USA and allies using native
American languages in WW2 to achieve the same thing, to send intelligence
data, for example.
Of course, if you use RANDOMISE without a number, it creates random numbers,
based on using the time value to seed the random number generator, about as
random as the Sinclair random number can get.
--
Dilwyn Jones
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm