True and True

  • Thread starter Thread starter Tim Childs
  • Start date Start date
T

Tim Childs

Hi

pl can someone explain why the ansers are negative in the extract from the
Immediate box

thanks

Tim

?true + true

-2



? True + TRUE

-2



?true + false

-1
 
Hi Tim
in VBA TRUE evaluates to -1 (opposed to 1 in Excel formulas)
so in your case TRUE + TRUE = (-1) + (-1) = -2 and TRUE + FALSE = (-1)
+ 0 = -1

HTH
Frank
 
Tim,

False is 0
True is actually better thought of as NOT 0.
In 8 bit binary:
00000000 = False
11111111 = True

If that binary number for True is represented as a signed byte, it turns out
to be -1
 
Frank

many thanks - it seems bizarre on the one hand but it certainly explains the
responses in the Immediate window

regards

Tim
 
Back
Top