Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QBJS v0.6.0 Release
#29
A logical AND, OR and NOT would be useful. -- Regarding the binary system: does anyone know why the following program returns (Not 10) And (Not 20) a result of -31?

Code: (Select All)
'Beispiel logische Operatoren, QuickBasic 4, Seite 3.10
'10. Nov. 2022

Dim As Integer a, b

a = 10
b = 20

Print: Print Tab(4); "a And b"
Print Tab(4); a And b

'Eine 1 ergibt sich nur, wenn beide Bits 1 sind.
'00001010 -> 10
'00010100 -> 20
'--------
'00000000

Print: Print Tab(4); "a Or b"
Print Tab(4); a Or b

'Eine 1 ergibt sich, wenn mindestens ein Bit eine 1 ist.
'00001010 -> 10
'00010100 -> 20
'--------
'00011110 -> 30 (16+8+4+2)

Print: Print Tab(4); "Not"
Print Tab(4); Not a '-> -11
Print Tab(4); Not b '-> -21

'Das Ausfuehren von NOT entspricht der Addition
'einer 1 zur Zahl mit anschliessender Negation

Print: Print Tab(4); "(Not a) And (Not b)"
Print Tab(4); (Not a) And (Not b) '-> -31

'-10 = 1000 1010
'-20 = 1001 0100
'---------------
'(1)1 001 1111 -> -31

'Klappt nur, wenn 0 + 0 = 1
'Addition zweier negativer Zahlen im Binaerformat

End
Reply


Messages In This Thread
QBJS v0.6.0 Release - by dbox - 11-07-2022, 01:43 PM
RE: QBJS v0.6.0 Release - by Pete - 11-07-2022, 04:32 PM
RE: QBJS v0.6.0 Release - by dbox - 11-07-2022, 05:08 PM
RE: QBJS v0.6.0 Release - by Pete - 11-07-2022, 06:26 PM
RE: QBJS v0.6.0 Release - by bplus - 11-07-2022, 07:17 PM
RE: QBJS v0.6.0 Release - by dbox - 11-08-2022, 07:20 PM
RE: QBJS v0.6.0 Release - by mnrvovrfc - 11-08-2022, 11:59 PM
RE: QBJS v0.6.0 Release - by mnrvovrfc - 11-07-2022, 07:53 PM
RE: QBJS v0.6.0 Release - by SpriggsySpriggs - 11-07-2022, 08:07 PM
RE: QBJS v0.6.0 Release - by dbox - 11-07-2022, 08:15 PM
RE: QBJS v0.6.0 Release - by mnrvovrfc - 11-07-2022, 08:17 PM
RE: QBJS v0.6.0 Release - by dbox - 11-07-2022, 08:40 PM
RE: QBJS v0.6.0 Release - by bplus - 11-08-2022, 07:31 PM
RE: QBJS v0.6.0 Release - by Pete - 11-08-2022, 07:34 PM
RE: QBJS v0.6.0 Release - by dbox - 11-08-2022, 07:51 PM
RE: QBJS v0.6.0 Release - by Coolman - 11-09-2022, 11:25 AM
RE: QBJS v0.6.0 Release - by dbox - 11-10-2022, 12:35 AM
RE: QBJS v0.6.0 Release - by Coolman - 11-10-2022, 11:33 AM
RE: QBJS v0.6.0 Release - by Pete - 11-10-2022, 02:31 AM
RE: QBJS v0.6.0 Release - by a740g - 11-10-2022, 01:46 PM
RE: QBJS v0.6.0 Release - by mnrvovrfc - 11-10-2022, 03:43 PM
RE: QBJS v0.6.0 Release - by dbox - 11-10-2022, 03:46 PM
RE: QBJS v0.6.0 Release - by a740g - 11-10-2022, 04:30 PM
RE: QBJS v0.6.0 Release - by dbox - 11-10-2022, 06:24 PM
RE: QBJS v0.6.0 Release - by a740g - 11-10-2022, 08:11 PM
RE: QBJS v0.6.0 Release - by CharlieJV - 11-10-2022, 08:40 PM
RE: QBJS v0.6.0 Release - by vince - 11-10-2022, 02:22 PM
RE: QBJS v0.6.0 Release - by Pete - 11-10-2022, 09:48 PM
RE: QBJS v0.6.0 Release - by Kernelpanic - 11-10-2022, 10:34 PM
RE: QBJS v0.6.0 Release - by vince - 11-10-2022, 11:48 PM
RE: QBJS v0.6.0 Release - by Kernelpanic - 11-11-2022, 12:30 AM
RE: QBJS v0.6.0 Release - by SMcNeill - 11-11-2022, 12:38 AM
RE: QBJS v0.6.0 Release - by Kernelpanic - 11-12-2022, 12:29 AM



Users browsing this thread: 8 Guest(s)