Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bitcount
Message
De
04/12/2014 10:20:44
 
 
À
04/12/2014 09:56:48
Lutz Scheffler (En ligne)
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
SAMBA Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01611745
Message ID:
01611820
Vues:
42
>>>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform