hp 20s RNG


Hello All:
I'm using a HP 20S, I know, please forgive, without RPL.
I have tried very hard with a limited math backgound to add lines to the Random Number Generator Sample Program (pgs 75-76 owners manual) to constuct a Scaled Random Number Generator with no sucess. I have been using 101 and 0 for the upper and lower limits and adding that command to either the eighth and ninth command lines with no success.
Yes, I know I am a biologist and shouldn't wonder far that science but I want to because this calcualtor is cool and more mobile than a computer.



If you store the lower limit in register 1 and the upper limit in register 2, then the following code should work for you. Note that the first nine lines are the same as in the manual. The extra lines are added to the end.

For the example you gave, store 0 in register 1 and store 101 in register 2 before calling the program with XEQ A. Each time you hit XEQ A, you will get another random number in the range defined by the numbers in register 1 and register 2.

Also, if this is the only program in memory, you can make sure that it is entered correctly by looking at the checksum, which should be 0xd229. Press SHOW when in program mode to display the checksum.


< Original Code in the manual >
01 LBL A
02 RCL 0
03 x
04 9
05 9
06 7
07 =
08 FP
09 STO 0

< New code that returns a random number in the range
defined by register 1 and register 2 >
10 RCL 2
11 -
12 RCL 1
13 =
14 x
15 RCL 0
16 +
17 RCL 1
18 =
19 RTN

Possibly Related Threads...
Thread Author Replies Views Last Post
  HP 20S Kate Field (Corvallis) 1 551 07-03-2013, 07:41 PM
Last Post: Peter Murphy (Livermore)
  HP 20S with very high "off" current Neil Hamilton (Ottawa) 2 588 04-01-2012, 11:49 AM
Last Post: Neil Hamilton (Ottawa)
  HP 20S recurring key identification Andrew 5 846 11-22-2010, 03:19 PM
Last Post: Walter B
  The 20s is apparently faster than the 32sii Dave Britten 48 5,044 01-05-2010, 06:20 PM
Last Post: Bart (UK)
  HP-20S Manual? Tom McCaffrey 1 498 10-26-2009, 10:25 PM
Last Post: Katie Wasserman
  HP 20S Self-Test Question Karen Allen 4 689 07-11-2008, 08:56 PM
Last Post: Karen Allen
  HP 20S colour scheme DaveJ 9 1,336 04-11-2008, 04:44 PM
Last Post: Walter B
  hp 20s self test Charles Oxford 6 987 12-23-2007, 05:25 PM
Last Post: Charles Oxford
  HP-20S and MEM command Antonio Maschio (Italy) 2 586 12-21-2007, 01:58 AM
Last Post: Antonio Maschio (Italy)
  hp 20s English Ver. Manual joshua 9 1,236 12-11-2006, 09:34 AM
Last Post: Frank E. Travis

Forum Jump: