Not

From REALbasicWiki

Jump to: navigation, search

The not operator operates on either Booleans or Integers (support for Integer was added in REALbasic 2007r2).

When operating on Booleans it is the standard Boolean negation operation, defined on values as follows.

not true = false
not false = true

When operating on an Integer it operates bitwise on the operand. It inverts the bits.

not 1 = 0
not 0 = 1

On arbitrary integers, and operates on the bits in the base 2 representations of the operands. Here is an example.

 dim i as integer = not 0
 
 if i = -1 then
    msgbox "i is -1"
 end if
 

0 in binary is all zero bits, 32 bits in this case, or &h00000000 (also &b00000000000000000000000000000000) not 0 turns all 0's to 1's i = &hffffffff or &b11111111111111111111111111111111

It turns out that this particular bit pattern represents the value -1 in binary

Personal tools
related