<-- Previous || Up || Next -->

Rnd Bytes Verify Sub
Random Values Class

Private Sub RndBytesVerify()
    ' "Random Bytes Verify"
    ' Print a frequency count of the bytes within values generated by the Visual Basic Rnd function.

    'See also:
    '  RndBitsVerify
    '  RndVerify

    Dim avarBytCnt() As Variant
    ReDim avarBytCnt(1 To 4, 0 To 255)

    Const NTries = 100000
    Const NReport = 10000

    Randomize

    Dim lngTry As Long
    For lngTry = 1 To NTries
        If lngTry Mod NReport = 0& Then Debug.Print Format$(lngTry, "#,##0")

        Dim sngRnd As Single
        Dim strRnd As String

        sngRnd = Rnd
        strRnd = MakeSingleFast(sngRnd)

        Dim intCurByt As Integer
        For intCurByt = 1 To Len(sngRnd)
            Dim intCurVal As Integer
            intCurVal = ASC(Mid$(strRnd, intCurByt, 1))

            avarBytCnt(intCurByt, intCurVal) = avarBytCnt(intCurByt, intCurVal) + 1&
        Next intCurByt
    Next lngTry

    Debug.Print FormatVariantMatrix(avarBytCnt, " ", vbCrLf)
End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.