|
-
Mar 30th, 2013, 02:51 PM
#10
Fanatic Member
Re: Looking for possible optimization of code to count bits (1's).
can be faster, just concatenate all those lines, and save a lot of memory writes
Public Function CountLetters(ByVal Value As Long) As Byte
CountLetters = (Value And &H1& ) - ((Value And &H2&) = &H2&) - ((Value And &H4&) = &H4&) - ((Value And &H8&) = &H8&) - ((Value And &H10&) = &H10&) - ((Value And &H20&) = &H20&) - ((Value And &H40&) = &H40&) - ((Value And &H80&) = &H80&) - ((Value And &H100&) = &H100&) - ((Value And &H200&) = &H200&) - ((Value And &H400&) = &H400&) - ((Value And &H800&) = &H800&) - ((Value And &H1000&) = &H1000&) - ((Value And &H2000&) = &H2000&) - ((Value And &H4000&) = &H4000&) - ((Value And &H8000&) = &H8000&) - ((Value And &H10000) = &H10000) - ((Value And &H20000) = &H20000) - ((Value And &H40000) = &H40000) - ((Value And &H80000) = &H80000) - ((Value And &H100000) = &H100000) - ((Value And &H200000) = &H200000) - ((Value And &H400000) = &H400000) - ((Value And &H800000) = &H800000) - ((Value And &H1000000) = &H1000000) - ((Value And &H2000000) = &H2000000) - ((Value And &H4000000) = &H4000000) - ((Value And &H8000000) = &H8000000) - ((Value And &H10000000) = &H10000000) - ((Value And &H20000000) = &H20000000) - ((Value And &H40000000) = &H40000000) - ((Value And &H80000000) = &H80000000)
End Function
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|