tincho   14-05-2023, 23:35
#23
Vuott paso un código en la lista de correo que usa la librería estándar libc.
Tome ese código y lo adapte un poco para usarlo como función, el rendimiento es excelente solo el doble de tiempo que el ID de Shordi .

Código:
' Gambas class file

Export

Library "libc:6"

' void srand (unsigned int __seed)
' Seed the random number generator with the given number.
'Private Extern srand(__seed As Integer)

' int rand (void)
' Return a random integer between 0 and RAND_MAX inclusive.
Private Extern rand_C() As Integer Exec "rand"

Static Public Sub Gen() As String

  ' "01/01/1970" is Unix Time Stamp - Epoch:
  Dim i As Integer
  Dim iRan As New Integer[]

  'srand(DateDiff("01/01/1970", Now, gb.Second))

  iRan.Clear

  For i = 0 To 5
    iRan.Add((Lsl(rand_C() And &03, 30)) Or (Lsl(rand_C() And &7fff, 15)) Or (rand_C() And &7fff))
  Next

  Return Hex(iRan[0], 8) & "-" & Hex(iRan[1] And &ffff&, 4) & "-" & Hex((iRan[2] And &0fff) Or &4000, 4) & "-" & Hex((iRan[3] And &3fff) + &8000, 4) & "-" & Hex(iRan[4] And &ffff&, 4) & Hex(iRan[5], 8)

End

' Private Function Rand32() As Integer
'
'   Return (Lsl(rand_C() And &03, 30)) Or (Lsl(rand_C() And &7fff, 15)) Or (rand_C() And &7fff)
'
' End

1 Saludo.
  
Usuarios navegando en este tema: 1 invitado(s)
Powered By MyBB, © 2002-2025 MyBB Group.
Made with by Curves UI.