Random Number within Limits 
Author Message
 Random Number within Limits

Im attempting to write a program in Modula2 on our VMS system
but have been experiencing difficulty obtaining a Random Number
that falls between certain limits (ie Greater than 0 But less than 21)

I am Importing the Mth$Random function from the MathematicsProcedures
module and giving it a Seed value that ranged from -100 to 1000 (and Many
Points in Between).  What I get back is always a negative value.

Could someone shed some light on How I could obtain these random numbers.

Thank You

Chris Darrigo



Sat, 03 Sep 1994 09:05:00 GMT  
 Random Number within Limits

#
# Im attempting to write a program in Modula2 on our VMS system
# but have been experiencing difficulty obtaining a Random Number
# that falls between certain limits (ie Greater than 0 But less than 21)
#
# I am Importing the Mth$Random function from the MathematicsProcedures
# module and giving it a Seed value that ranged from -100 to 1000 (and Many
# Points in Between).  What I get back is always a negative value.
#
# Could someone shed some light on How I could obtain these random numbers.

  Most random-number packages do this by generating a normalized
  REAL (in the 0..1 range) and multiplying by the range of the
  numbers desired.  This is typically quite slow unless you have
  a Cray or similar floating-point oriented machine.

  For most of us, it's better to narrow the range of a fast integer
  random number routine (read Knuth) with a mask, then discard
  out-of-range numbers.  On the average, you'll only have to toss
  half at worst.
--
| The above opinions may not be original, but they are mine and mine alone. |
|        "While it may not be for you to complete the task,                 |
|         neither are you free to refrain from it." -- R. Tarfon            |
+-=-=-    (I wish _this_ were original!)        D. C. Sessions         -=-=-+



Mon, 05 Sep 1994 04:13:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Random Number Generator to produce SAME random number from 12:00am-11:59pm

2. Random number not random?

3. Pentium III processor number and random number generator

4. limits for pipes within OS/2?

5. Add time within a Time limits handler

6. Limited number of entires in HandleRegistry

7. Number limits?

8. Limit on number of input fields?

9. Limited number of menu items?

10. Limits on memory/number of objects?

11. C5ABC Limiting number of users template/extension

12. Limit on the number of menu itens?

 

 
Powered by phpBB® Forum Software