Bit-Operator not working ? lazarus / 61-Beginners ---------------------------------------------------------------------- mb · 2018-07-01 12:54 Hi guys, short but very funny problem (as I always have) ...  Why is THIS not working ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i value:=$4D and $20; 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) ---------------------------------------------------------------------- engkin · 2018-07-01 12:57 You most likely meant to use OR, not AND. ---------------------------------------------------------------------- mb · 2018-07-01 13:02 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i value:=$4D or $20; returns "109" as result. 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? ---------------------------------------------------------------------- engkin · 2018-07-01 13:11 109 is $6D. What are you expecting? ---------------------------------------------------------------------- Thaddy · 2018-07-01 13:18 @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. ---------------------------------------------------------------------- Handoko · 2018-07-01 13:18 I used SpeedCruch calculator, it gives this results: Quote77 and 32 = 0 77 or 32 = 109 $4D = 77 $20 = 32 So, everything is working correctly. https://en.wikipedia.org/wiki/Bitwise_operation ---------------------------------------------------------------------- mb · 2018-07-01 13:23 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. I expected $40, but that wound be: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $4D and $40 of course ... sorry ... but thanks for your answer, that gave me the hint. Thank you ! Sorry guys ... But it is a great community and I am happy I found Lazarus and this forum! ---------------------------------------------------------------------- avra · 2018-07-01 17:16 Quote from: mb on July 01, 2018, 02:54:53 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i value:=$4D and $20; value is of type "byte". 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: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if value.Bit[5] then  SomeString := value.Bit[5].ToTrueFalseString; ---------------------------------------------------------------------- Handoko · 2018-07-01 18:10 Quote from: avra on July 01, 2018, 07:16:50 pmIf you just want to test a bit state then you could use BitHelpers from here: https://bitbucket.org/avra/bithelpers. That's interesting. Thank you for sharing it.