push_rand Function (ROM Call 0x31F)

AMS 1.01 or higher basfunc.h

void push_rand (CESI Range);

Executes TI-Basic 'rand' function.

push_rand pushes a random number on the expression stack. Range should point either to END_TAG, or to an integer expression. If Range points to END_TAG, push_rand pushes a floating point number between 0 and 1. If Range points to an integer value n, push_rand pushes an integer number between 1 and n if n is positive, or between -n and -1 if n is negative.

Note: This function calls the TI-Basic random number generator, so it has nothing to do with the random number generator from stdlib.h (i.e. with the functions rand, random, randomize, and srand). You can use the function cmd_randseed (instead of srand) to set the seed for the TI-Basic random number generator. Note also that push_rand is much slower than the random number generator implemented in stdlib.h.


Uses: delete_between, estack_number_to_Float, push_expression, push_Float, push_Float_to_rat, push_quantum, top_estack, memcpy, fabs, fpisanint, is_transfinite, estack_to_float, is_whole_number, is0, NG_control, primary_tag_list, _bcd_math


See also: cmd_randseed, rand, random