Wednesday, November 09, 2005

Range limitation in TIbasic rand() function

rand(n) returns a random integer in the range [1,n]. The maximum (undocumented) value for 'n' is 99,999,999,999,999, or only 14 digits. Would be handy to have a function to extend the argument range to the full integer range of 640 digits or so. The function should retain the good statistical properties of the built-in rand() function, so the question becomes: what is the best way to combine multiple results from rand() to build a larger integer? Probably already plenty of results for this already; need to search. Also remember to handle negative arguments for 'n'.

0 Comments:

Post a Comment

<< Home