[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Random Statement
- Subject: Re: Random Statement
- From: nathan@visi.com (Nathan Mates)
- Date: 1996/11/29
- Newsgroups: comp.sys.apple2
- Organization: (missing)
- References: <57lu0m$3po@news.skyenet.net>
In article <57lu0m$3po@news.skyenet.net>, <tbird@skyenet.net> wrote:
>10 let a = Rnd(1)*170
>20 if a <20 then goto (somewhere)
>30 if a >150 then goto (somewhere else)
>howcome sometimes in the middle of the program the number from the random
>statement is under 20 and over 150.
It can't be both under 20 and over 150 at once. Therefore, either
you're not explaining what's going on, or something else.
> A rnd(20)*150 isn't correct... I'm
>stuck,please help...?
Assuming you're using Applesoft Basic, RND(1) returns a floating
point value, 0<=Value<1. Thus, RND(1)*170 will range from 0<=Value<170.
If you want a number from 20 to 150, why not just do
A=INT(RND(1)*151)+20
Nathan Mates
--
<*> Nathan Mates http://www.visi.com/~nathan/ <*>
# What are the facts? Again and again and again-- what are the _facts_?
# Shun wishful thinking, avoid opinion, care not what the neighbors
# think-- what are the facts, and to how many decimal places? -R.A. Heinlein