Quote:
Originally posted by rbayer
As for the integer math, that only works assuming that bytevarX will never be bigger than the value you are testing for. If it could be, then the behavior is rather sporadic. For example. bitVarY=5/10 will assign the value 0 to bitVarY since the lowest-order bit of 5/10 (= 10b) is zero, wheras 5/15 (=11b) will assign it the value 1.
|
What about this:
Code:
bitVar = byteVAR / a MAX 1 'byteVar >= a
bitVar = a / (byteVAR MIN 1) MAX 1 'byteVar <= a
bitVar = (byteVAR / a) * (a / (byteVAR MIN 1) ) MAX 1 'byteVar == a (doesn't work for a=0)
Albeit, that fix makes it more bloated than helpful for the equality test. Here's an option I just thought of for an equality test (don't you just love bit fidling?)
Code:
bitVar = 0 ** (byteVAR - a) 'byteVar == a
If byteVAR == a, it will end up being 0^0, which is usually defined as one (although, I can't confirm the stamp will return 1). Otherwise, it will return 0. There is the case if byteVAR is less than a, then we have 0 ^ (- k), and that is a division by zero error (or maybe the stamp just returns 0?). You could fix that with a MIN statement though. I don't know how fast MIN and MAX statements are, so there is the highly likely chance that all this is futile, and Dr. Joe's way is much faster
Stephen