I created the following random-number-between-borders generator
Use: place maxNumber and minNumber on the stack (the order is irrelevant, negative numbers allowed) and run >random<.
\ N.B. Scamp3 random ( -- u )
\ Retrieves an unsigned 16-bit random number from the hardware RNG.
\ This is a true random number, not a pseudo-random number.
\ Generate random integer in the range n1 - n2
random< ( n1 n2 -- )
2dup <
if swap then
swap 1+ swap
2dup -
random
swap /mod
drop
abs
+
swap drop
;
I created the following random-number-between-borders generator
Use: place maxNumber and minNumber on the stack (the order is irrelevant, negative numbers allowed) and run >random<.
\ N.B. Scamp3 random ( -- u )
\ Retrieves an unsigned 16-bit random number from the hardware RNG.
\ This is a true random number, not a pseudo-random number.
Any suggestions for improvement?