Linear congruential generator: Difference between revisions

Line 3,146:
</pre>
 
=={{header|VBA}}==
<lang vb>Public stateBSD As Variant
Public stateMS As Variant
Private Function bsd() As Long
Dim temp As Variant
temp = CDec(1103515245 * stateBSD + 12345)
temp2 = temp / 2 ^ 31
temp3 = CDec(WorksheetFunction.Floor_Precise(temp2))
stateBSD = temp - (2 ^ 31) * temp3
bsd = stateBSD
End Function
Private Function ms() As Integer
Dim temp As Variant
temp = CDec(214013 * stateMS + 2531011)
temp2 = temp / 2 ^ 31
temp3 = CDec(WorksheetFunction.Floor_Precise(temp2))
stateMS = temp - (2 ^ 31) * temp3
ms = stateMS \ 2 ^ 16
End Function
Public Sub main()
stateBSD = CDec(0)
stateMS = CDec(0)
Debug.Print " BSD", " MS"
For i = 1 To 10
Debug.Print Format(bsd, "@@@@@@@@@@"), Format(ms, "@@@@@")
Next i
End Sub</lang>{{out}}
<pre> BSD MS
12345 38
1406932606 7719
654583775 21238
1449466924 2437
229283573 8855
1109335178 11797
1051550459 8365
1293799192 32285
794471793 10450
551188310 30612</pre>
=={{header|X86 Assembly}}==
 
255

edits