Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bitcount
Message
From
04/12/2014 09:27:04
 
 
To
04/12/2014 09:01:04
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
SAMBA Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01611745
Message ID:
01611806
Views:
46
>>>Hi all,
>>>
>>>Problem is I need to do do something as a multipple of the bits set on an integer, the integer is a bit array to store statii.
>>>
>>>I need to figure out how many bits are set on an integer.
>>>I know I can loop / iterate through the number and bittest / divide by 2 etc.
>>>for now there are not to much so I can do with an ICASE, but I like it generic :)
>>>Any ideas for a fast solution? Something mathematical?
>>>
>>
>>
>>Maybe a loop using BitTest()?
>>
>
>cite
>>>I know I can loop / iterate through the number and bittest / divide by 2 etc.
>/cite
>
>:D
>
>I look for something without a loop.


You can always unroll the loop into a single line adding iif(bittest(),1,0) if start and endpoint are fixed....
Are you certain optimizing that piece of code is neccessary ?
If such a short vfp loop has to be avoided because of using that line/loop/function billions at least, uncertain if vfp's slow function call used for a C-fll would get you faster times than a long vfp-line calling often into the C-runtimes...

feels like premature optimization on pure reading ;-)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform