Thou spake:
>>-----Original Message-----
>
>From: Ron Johnson [mailto:ron.l.johnson@cox.net]
>
>>Sent: Thursday, August 14, 2003 2:50 PM
>>To: NOLUG ML
>>Subject: [Nolug] Random numbers in bash
>>
>>
>>Hi,
>>
>>Anyone know if that's possible? For example, I'd like to generate
>>a random number between 1 and 100.
>>
>>Thanks
>
>$RANDOM returns a number between 0 and 32767
I wrote a dice-rolling program on my HP 41C calculator in college sometime
during the last millenium. Basically, here's what I did:
Take the range of possible values and multiply by some factor that will give
you results in the range you are looking for. You might have to take this
number and add 1 to it (else you'll be getting a zero, which is outside your
stated range). Then round the real value and cast it to get an integer
(different languages cast differently, you'll have to research this).
Hope this helps :-)
-- Joey Kelly < Minister of the Gospel | Computer Networking Consultant > http://joeykelly.net "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." ___________________ Nolug mailing list nolug@nolug.orgReceived on 08/14/03
This archive was generated by hypermail 2.2.0 : 12/19/08 EST