- Open Microsoft Excel
- Save the Excel file as Macro Enabled file
- Alt+F11 to open the VBA Editor and input below function
Function AddDigits(Number As Long) As Integer
Dim i, n As Integer
Dim Sum As Integer
Dim sNumber As String
sNumber = CStr(Number)
For i = 1 To Len(sNumber)
n = CInt(Mid(sNumber, i, 1))
If (n <= 0) Then
n = -1
End If
Sum = Sum + n
Next
AddDigits = Sum
End Function- Input Cell A1 for the Binary Digits); And in B1 use the function by "=AddDigits(A1)"
- Use the formula from this link: https://i.stack.imgur.com/6iZU8.png
Reference for the Formula: (NIST) A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications - Dr. Andrew Rukhin, et.al
Aucun commentaire:
Enregistrer un commentaire