Joined: February 2nd, 2006, 10:38 pm

August 23rd, 2012, 2:30 pm #91

In fact the range QB1.1 and QB4.5 prints to the screen is wrong anyhow. If it can use TIMER values that range is too low. QB4.5 Help uses:

RANDOMIZE [expression]

This also makes it appear to be optional when it will ask if it is not used.
Quote
Like
Share

Joined: April 5th, 2005, 9:24 pm

February 20th, 2013, 6:01 am #92

CLS
FOR i = 1 TO 5: gosub RND1: next i
PRINT "------"
Seed# = y#(1)
FOR i = 1 TO 5: gosub RND2: next i
SYSTEM

RND1: ' ***** ***** This is the number produced by RND
y#(i) = RND * 16777216
PRINT y#(i)
return

RND2: ' ***** ***** This is the number produced by zombie
PRINT Seed#
Temp# = (16598013# * Seed# + 12820163)
Seed# = Temp# - INT(Temp# / 16777216) * 16777216
return
http://www.network54.com/Forum/178565/m ... D+function
Quote
Like
Share

Joined: April 5th, 2005, 9:24 pm

February 21st, 2013, 8:56 am #93

DECLARE SUB qRandomizeUsing (s AS SINGLE)
DECLARE FUNCTION qRnd! ()
DIM SHARED qSeed AS LONG
qSeed = &H50000

SUB qRandomizeUsing (s AS SINGLE)
 ' derived from: QB64 0.942 win32: libqbx.cpp: sub_randomize
' this would be so much simpler with unsigned math

 qSeed = CVL(RIGHT$(MKD$(s), 4))
 qSeed = (((qSeed XOR INT(qSeed / &H10000)) AND &HFFFF&) * &H100)
END SUB

FUNCTION qRnd!
 ' derived from:
 ' http://www.network54.com/Forum/178387/m ... 046747461/
 ' this would be so much simpler if overflow could be ignored.

 DIM t AS DOUBLE
 t = qSeed
 t = (&HFD43FD * t + &HC39EC3)
 qSeed = t - INT(t / &H1000000) * &H1000000
 qRnd = qSeed / &H1000000
END FUNCTION
* As indicated in the QB64 source code, the initial state is 0x50000.
Last edited by MCalkins on February 21st, 2013, 9:02 am, edited 1 time in total.
Quote
Like
Share

Joined: April 5th, 2005, 9:24 pm

March 23rd, 2015, 1:18 pm #94

* or by PRINT HEX$(RND(0) * 2 ^ 24)
Quote
Like
Share