Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bitcount
Message
From
04/12/2014 10:20:44
 
 
To
04/12/2014 09:56:48
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:
01611820
Views:
43
>>>>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 ;-)
>>>
>>>It's just out of curiosity. Nothing important, just an intellectual problem. I do someting like
>>>
>>>?icase(num=0,0,num=3,2,1)
>>>
>>>
>>>on the 2 bit thing and found it boring with bit 2 on.
>>>
>>>:)
>>
>>
>>I think he means
>>
>>
>>nBIts = iif(bitTest(num, 0), 1, 0) + iif(bitTest(num, 1), 1, 0) + ..... iif(bitTest(num, 31), 1, 0)
>>
>>
>>Alternatively, you can precompute for 0-255 and put the results in an array
>>
>>
>>nBits = Array[ 1 + bitand(num, 0xff)] + Array[ 1 + bitand( bitrshift(num, 8), 0xff)] + Array[ 1 + bitand( bitrshift(num, 16), 0xff)]  + Array[ 1 + bitand( bitrshift(num, 24), 0xff)]
>>
>
>Yes I understand this.
>
>I realy look for something pretty. Loops, IIF and the like are clumsy. :)


Personally, I'd go for the precomputed solution
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform