A nada, dejemoslo ahi por que ultimamente lo unico que se hace es discutir en este sub foro.
Tema solucionado.
Edit: solo por curiosidad arme esto, posiblemente a alguien le interese
Tema solucionado.
Edit: solo por curiosidad arme esto, posiblemente a alguien le interese
Código (vb) [Seleccionar]
Option Explicit
'Reference
'http://world.std.com/~franl/crypto/random-numbers.html
'ANSI C (rand())
Public Function ANSI_C_Rand(Optional lSeed As Long) As Long
Static SEED As Double
If Not lSeed = 0 Then SEED = lSeed
SEED = CustomMod((1103515245 * SEED + 12345), 2 ^ 31)
ANSI_C_Rand = SEED
End Function
'Microsoft C v4.0 rand()
Public Function Microsoft_C_Rand(Optional lSeed As Long) As Long
Static SEED As Double
If Not lSeed = 0 Then SEED = lSeed
SEED = CustomMod((214013 * SEED + 2531011), 2 ^ 31)
Microsoft_C_Rand = Int(SEED / 2 ^ 16)
End Function
'Turbo Pascal v6.0 (random)
Public Function Turbo_Pascal_Rand(Optional lSeed As Long) As Long
Static SEED As Double
If Not lSeed = 0 Then SEED = lSeed
SEED = CustomMod((134775813 * SEED + 1), 2 ^ 32)
Turbo_Pascal_Rand = Int(SEED / 2 ^ 16)
End Function
'// Custom mod to prevent overflow
' This is not mine is from a RSA implentation I found on PSC
Private Function CustomMod(ByVal dVal1 As Double, ByVal dVal2 As Double) As Double
CustomMod = dVal1 - (Int(dVal1 / dVal2) * dVal2)
End Function