Re: Get Random number?
Re: Get Random number?
- Subject: Re: Get Random number?
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 14 Aug 2007 17:45:49 -0400
On 8/14/07, Jakob Peterhänsel <email@hidden> wrote:
> Hi All,
>
> Anyone have a method to get a random number in AS?
>
> Native or via do shell script ?
For a pseudo-random number with only 15 bits of precision, you can use
the shell's $RANDOM variable:
set randomNumber to do shell script "echo $RANDOM";
which will get you a random integer uniformly distributed between 0
and 32767, inclusive. You can then take the remainder with respect to
some integer (if you're looking to simulate a dice roll or similar) or
divide by 32768 to get a float in the [0,1) range.
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden