× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



PAPWORTH Paul wrote:
I have set up a bit of test code to better understand this and it works fine for the free form equivalents of TESTB and BITON. However in order to complete the cycle how could I setoff bit 2 ?

Simon's suggestions will work, but to help understand why I'll try to quickly explain how I came up with the "mask" value in the code sample earlier. Look at the definition of the operations:

AND OR
x | y | x AND y x | y | x AND y
------------------ ------------------
0 | 0 | 0 0 | 0 | 0
0 | 1 | 0 0 | 1 | 1
1 | 0 | 0 1 | 0 | 1
1 | 1 | 1 1 | 1 | 1


Notice that *1 AND y = y* and also *0 AND y = 0*. So if we have the mask=010, what are the possible results of %bitand(mask : value)? The first and third bits of the result will be 0, and the second bit will have whatever value the second bit in value has.

%bitand(010 : x1y) = 010 for any x,y
%bitand(010 : x0y) = 000 for any x,y


For setting bits, notice that *0 OR y = y* and and *1 OR y = 1*. Following similar logic, you can see that

%bitor(010 : x1y) = x1y for any x,y
%bitor(010 : x0y) = x1y for any x,y

HTH,
Adam

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.