value is of type "byte". Using "+" operator works fine, with correct result, but bit-operator is not working ... %) I am always getting "0" as result, but it should be 32d (20h)
Title: Re: Bit-Operator not working ?
Post by: engkin on July 01, 2018, 02:57:08 pm
You most likely meant to use OR, not AND.
Title: Re: Bit-Operator not working ?
Post by: mb on July 01, 2018, 03:02:55 pm
I dont understand this, every book I have explains it like I used it, but its not workung for me. Do I have to include some libary or something?
Title: Re: Bit-Operator not working ?
Post by: engkin on July 01, 2018, 03:11:12 pm
109 is $6D. What are you expecting?
Title: Re: Bit-Operator not working ?
Post by: Thaddy on July 01, 2018, 03:18:25 pm
@mb Than your "book" must be more like a reactionary pamphlet: And means leave in all set bits that are common to both. It does not mean addition. Or means include the bits that are set in either one or the other.
Title: Re: Bit-Operator not working ?
Post by: Handoko on July 01, 2018, 03:18:44 pm
I used SpeedCruch calculator, it gives this results:
Quote
77 and 32 = 0 77 or 32 = 109
$4D = 77 $20 = 32
So, everything is working correctly. ;D
https://en.wikipedia.org/wiki/Bitwise_operation
Title: Re: Bit-Operator not working ?
Post by: mb on July 01, 2018, 03:23:08 pm
DAMN .... 1 bit ... your right! Too much heat here in my room today. I am very sorry, a typical mistake ... took me now about an hour of time.
If you just want to test a bit state then you could use BitHelpers from here: https://bitbucket.org/avra/bithelpers. Your code would look like this then: