QB64 Phoenix Edition
QBJS v0.6.0 Release - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: QBJS, BAM, and Other BASICs (https://staging.qb64phoenix.com/forumdisplay.php?fid=50)
+--- Thread: QBJS v0.6.0 Release (/showthread.php?tid=1069)

Pages: 1 2 3 4


RE: QBJS v0.6.0 Release - Kernelpanic - 11-11-2022

(11-10-2022, 11:48 PM)vinceplease review Steve's useful tutorial on bitwise operations Wrote: https://staging.qb64phoenix.com/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?


RE: QBJS v0.6.0 Release - SMcNeill - 11-11-2022

(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://staging.qb64phoenix.com/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


RE: QBJS v0.6.0 Release - Kernelpanic - 11-12-2022

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]