Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QBJS v0.6.0 Release
#31
(11-10-2022, 11:48 PM)vinceplease review Steve's useful tutorial on bitwise operations Wrote: https://qb64phoenix.com/forum/showthread.php?tid=305

I can't find anything there for my question. The question is like this:
NOT(10) = -11 -- That is fine and understanding
NOT(20) = -21 -- The same

But why is then: Not(10) AND Not(20) = -31?
Reply
#32
(11-11-2022, 12:30 AM)Kernelpanic Wrote:
(11-10-2022, 11:48 PM)vinceplease review Steve's useful tutorial on bitwise operations Wrote: https://qb64phoenix.com/forum/showthread.php?tid=305

I can't find anything there for my question. The question is like this:
NOT(10) = -11 -- That is fine and understanding
NOT(20) = -21 -- The same

But why is then: Not(10) AND Not(20) = -31?

-11 = &B1111111111110101
-21 = &B1111111111101011
AND ================
          &B1111111111100001


-31 = &B1111111111100001
Reply
#33
Thanks for the explanation, but basically it's very simple: NOT(a) AND NOT(b) is the same as 10 + 20 = 30 plus 1 and subsequent negation = -31.

It just doesn't always seem to work: 1, 2 are correct, but 3 is muddled, and 4 is correct again. At number 3 should be result: -51 -- Where is the mistake?


Code: (Select All)
Dim As Integer a, b, c

a = 10
b = 20
c = 40

Print
Print "1"
Print (Not a) And (Not b)

Print
Print "2"
Print (Not c)

Print
Print "3"
Print (Not a) And (Not c)

Print
Print "4"
Print (Not b) And (Not c)

[Image: Logisch-Binaere-Operatoren2022-11-12.jpg]
Reply




Users browsing this thread: 2 Guest(s)