rand16

Description

This function returns a psuedo random number. It uses a 16 bit shift register with xor feedback. The sequence of generated numbers does not repeat within 65,535 shifts.

This function will only return a maximum of 16 bits. Numbers greater than this can be built using multiple rand16 calls.

e.g.
	// generating a 19 bit random number
	ulong	acc

	acc = rand16(3) << 16
	acc = acc | rand16(16)

Definition

uint rand16(uint cnt)

Library

LIB/rand_lib.bas

Usage

On entry:
cnt is the number of bits that should be returned. The maximum number is 16.
On exit:
Return a random number in the range 0 to (2^cnt)-1 (2 to the power cnt minus 1). If cnt is 4 the returned number will be in the range 0 to 15