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


Possibly Related Threads…
Thread Author Replies Views Last Post
  QBJS v0.10.0 - Release dbox 7 1,020 01-12-2026, 01:00 PM
Last Post: dbox
  QBJS v0.9.0 - Release dbox 31 6,009 04-23-2025, 01:14 AM
Last Post: dbox
  QBJS v0.8.0 - Release dbox 11 2,332 02-13-2024, 10:11 PM
Last Post: grymmjack
  QBJS v0.8.2 - Release dbox 0 559 02-02-2024, 11:29 PM
Last Post: dbox
  BAM: Release notes in the works for upcoming release CharlieJV 6 1,411 10-12-2023, 01:42 AM
Last Post: CharlieJV

Forum Jump:


Users browsing this thread: 1 Guest(s)