--- title: "Random Numbers, Etc." type: "article" slug: "random-numbers-etc" url: "http://localhost/article/random-numbers-etc/" markdown_url: "http://localhost/article/random-numbers-etc.md" published_at: "2022-10-07T12:28:28+00:00" modified_at: "2026-07-30T11:03:40+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "by H. L. Schaaf A few months ago Duane Parker and I had been talking about random numbers. I told him about a program that I had done which gives the seed of any random number, that is to say it works in reverse of the random number generator. Others may also be interested, so…" category: - name: "CATS Newsletter" slug: "cats-newsletter" taxonomy: "category" url: "http://localhost/category/periodicals/cats-newsletter/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Herb Schaaf" slug: "herb-schaaf" taxonomy: "indiv" url: "http://localhost/indiv/herb-schaaf/" publication_r: id: 35941 title: "CATS Newsletter" type: "periodical" url: "http://localhost/periodical/cats-newsletter/" authors_r: - name: "Herb Schaaf" slug: "herb-schaaf" taxonomy: "indiv" url: "http://localhost/indiv/herb-schaaf/" volume: "6" issue: "1" issues_articles: - id: 39632 title: "CATS v6 n1" type: "issue" url: "http://localhost/issue/cats-v6-n1/" pages: "7" pubdate: "May 1988" archive_link: false --- # Random Numbers, Etc. *by H. L. Schaaf* A few months ago Duane Parker and I had been talking about random numbers. I told him about a program that I had done which gives the seed of any random number, that is to say it works in reverse of the random number generator. Others may also be interested, so here it is.. While in 2068 format, it’s easy to modify for the ZX-81 and QL. ### BASIC Listing[1](#rnd-fn1)[2](#rnd-fn2)[3](#rnd-fn3)[4](#rnd-fn4) ``` 10 REM "seed<-->RND" 20 LET a=2^16 25 LET b=a+1 30 LET c=52 40 LET d=74 50 LET e=d+1 60 LET f=.5 70 PRINT "You enter the value you want to come up as the next random # ." 80 PRINT '"If you enter a number between Zero and Unity ( 0 to 1 ) Then it will be converted to an integer multiple of 65535." 90 PRINT '"You may enter an integer betweenZero and 65535 and the decimal value (0 to 1) will be shown"'' 100 INPUT "Random number between 0 & 65535 that you want to know seed of ";r 102 IF r<0 THEN PRINT "POSITIVE VALUES ONLY !"''"Press ENTER to restart": PAUSE 0: RUN 103 IF r>1 AND (r-INT r)<>0 THEN PRINT "INTEGERS ONLY !"''"Press ENTER to restart": PAUSE 0: RUN 105 IF r>1 THEN LET r=INT (f+r*a) 107 IF r=74 THEN FLASH 1: PRINT "That's a tough one ! The seed of ZERO will NOT be predictable !!": PRINT '" RANDOMIZE 74 gives the longest nonrepeating run of random numbers.": FLASH 0: PRINT 110 PRINT "For RND = ";r;" ( ";r/a;" )" 120 LET x=r-d 125 LET x=INT ((x-((INT (x/e))*e))+f) 130 LET x=x*c 140 LET x=INT ((x-((INT (x/e))*e))+f) 150 LET seed=INT (((x*b+r-d)/e)+f) 160 PRINT "RANDOMIZE ";seed;" and then RND" 200 REM rnd from seed 205 PRINT '"Given a seed this will find the Resulting RND the hard way." 210 INPUT "seed ? ";seed 220 PRINT seed, 230 LET random = (seed*75+74) 250 IF randomrnd conversion and generation if anyone cares. Now what I’d like to see is an explanation of just how the QL does its random numbers!