Whenever I try to use the "randInt(" command on my TI-84+ SE it says, "ERR:OVERFLOW". It worked fine before. I don't know what is wrong. Help would be appreciated!
When in doubt, try reseeding the RNG.

Code:
0->rand
Can you give us an example of a line you are executing that is causing the problem?

Tari wrote:
When in doubt, try reseeding the RNG.

Code:
0->rand


Keep in mind that whenever you issue this command, your "random" numbers will follow the same sequence.
Thanks! It works now!
Tari wrote:
When in doubt, try reseeding the RNG.

Code:
0->rand
What does that exactly do? Does it somehow say out of which number the "random" numbers are calculated?
Sorunome wrote:
Tari wrote:
When in doubt, try reseeding the RNG.

Code:
0->rand
What does that exactly do? Does it somehow say out of which number the "random" numbers are calculated?


Simpler random number generators work by starting with a certain number, and then each time you want a new random number, it'll do something like multiply the number by some arbitrary number (like .123456789 or .54321876) and then add another arbitrary number to it (again, like .12345), and will then consider that "random". When you re-seed the generator, you get the same sequence of results every time you use rand because it starts with the same number as the seed, and multiplies/adds the random numbers on top the same each time. The trick is to start with something rather naturally random as the seed, like a Timer ID/ Timer Status, and then don't reseed it more often than you need to (if at all).
It's also useful for experiments or debugging where you want to be able to reuse the same PRNG sequence on multiple trials—just use the same seed again.

I remember the “overflow” problem being mentioned frequently back in the TI-82/85 ASM days after people would run certain programs. I guess the seed value in RAM would get corrupted and cause the error until the seed was manually reset to a valid value.
Travis wrote:
I remember the “overflow” problem being mentioned frequently back in the TI-82/85 ASM days after people would run certain programs. I guess the seed value in RAM would get corrupted and cause the error until the seed was manually reset to a valid value.
Exactly this. I've never quite understood why the OS doesn't choose to reset the rand seed to a sane value if it's a non-number; either TI's engineers didn't think to catch and handle that error, or they decided it would be the least confusing behavior since you might not suddenly expect your rand to be reseeded.
To mimic seeding rand:

PROGRAM:RANDSEED
:abs(int(Ans→X
:2^31-{85,249→u(nMin)
:4E4+{14,692→v(nMin)
:{XAns(1),X
:15{823,4526}not(X)+Ans-u(nMin)int(Ans/u(nMin)→w(nMin)

To mimic rand:

PROGRAM:RAND
:v(nMin)w(nMin)
:Ans-u(nMin)int(Ans/u(nMin)→w(nMin)
:fPart(1-min(ΔList(Ans/u(nMin)

This is good up to and including X=109-1. Why the native variety takes a different course is anyone's guess.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement