3Eh FN$RND calculate
Input - none -.
Output Floating-point result on the stack.
Description

Pushes a random floating-point number onto the run-time stack. The number will always lie between 0 and 0.999999999999 inclusive. The stack pointer (RTA_SP) is decremented by 8.

The seed for the random number generator is held in the 7 bytes at FNT_SEED. If these bytes are set to a particular value then the sequence of random numbers following this will always be the same.

See also: technical manual > utility system services > floating point numbers

Example The following subroutine will place a random floating-point number in FN_RESULT.
        OS      FN$RND          ;call random number generator
        LDX     RTA_SP:         ;source address for copying result
        LDD     #8
        STD     UTW_S0:         ;length for copying result
        ADDD    RTA_SP:         ;add 8 to stack pointer
        STD     RTA_SP:         ;restore stack pointer
        LDD     #FN_RESULT      ;destination for copy
        OS      UT$CPYB
        RTS

    FN_RESULT:
        DS      8
Errors 247 - bad argument in function call