Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:43 23 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Random number

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 09:44pm 14 Jan 2024
Copy link to clipboard 
Print this post

I'm sure I used to know this but have forgotten. How would I generate a random number between say 1 and 70. The manual says....
  Quote  RND( number )
or
RND
Returns a pseudo-random number in the range of 0 to 0.999999. The
'number' value is ignored if supplied. The RANDOMIZE command reseeds
the random number generator.

I cant figure it out.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
PEnthymeme

Regular Member

Joined: 27/12/2023
Location: United Kingdom
Posts: 42
Posted: 09:54pm 14 Jan 2024
Copy link to clipboard 
Print this post

I use int((rnd*70)+1)

RND generates from 0 to up to but not including 1
x 70
+ 1 shifts it to 1 to 70
Int rounds them all down to the nearest integer
Edited 2024-01-15 07:55 by PEnthymeme
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 2006
Posted: 07:29am 17 Jan 2024
Copy link to clipboard 
Print this post

Ok thanks for that.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025