ISO C Random

This algorithm generates a random number.



									Public Shared Function ISOCRandom(seed As UInteger) As Integer
	Dim [next] As ULong = seed
	Dim result As Integer

	[next] = ([next] * 1103515245) And UInteger.MaxValue
	[next] = ([next] + 12345) And UInteger.MaxValue
	result = (CInt(CUInt([next] \ 65536) Mod 2048)) And Integer.MaxValue

	[next] = ([next] * 1103515245) And UInteger.MaxValue
	[next] = ([next] + 12345) And UInteger.MaxValue
	result <<= 10
	result = (result Xor CInt(CUInt([next] \ 65536) Mod 1024)) And Integer.MaxValue

	[next] = ([next] * 1103515245) And UInteger.MaxValue
	[next] += ([next] + 12345) And UInteger.MaxValue
	result <<= 10
	result = (result Xor CInt(CUInt([next] \ 65536) Mod 1024)) And Integer.MaxValue

	seed = [next] And UInteger.MaxValue

	Return result
End Function
								


Example

									Dim value = ISOCRandom(CUInt(DateTime.Now.Millisecond))
								


Output

									1798100440