>>>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. :)
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord
Weeks of programming can save you hours of planning.
OffThere is no place like [::1]