Re: True = -1 ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Jonathan Wood" <jwood@xxxxxxxxxxxxxxxx> wrote

> I can't for the life of me understand why he continues to call VB's AND, OR,
> XOR, etc. operators *logical*. They are bitwise, and that is why True should
> be -1 in VB. If VB supported logical AND, OR, XOR, etc. operators, then it
> wouldn't matter if True was -1 or 1, or 45 for that matter.

I've always thought he's confused the issue, myself. But, I approve of calling
them logical operators because they correspond to the named 'logic' gates found
in electronics. Individual gates typically act on individual bits....

What I didn't like was the (abstracted) distinction between logical operations, and
boolean tests:

<quote>
First, understand that logical operations and tests are two different things.

For tests only (that is, the expression tested by IF and whatnot), a zero value
is judged to be false, any nonzero value is judged to be the truth (well, True).
</quote>

The sentence, "For tests only..." is clearly a misleading statement:

Debug.Print CBool(1)

Where is there any sort of 'test' in that??? Yet it results in a True or False result
depending on the numerical value used....

A more concise explaination:

VB's logical operations yield numerical results based on bitwise comparisons. If the
result is not 0, then it is regarded as being True. VB's value of True is an Integer
based on the result of the logical operation: X = Not False.

That is all there needs to be said on that topic.

LFS







.



Relevant Pages

  • Re: puzzle
    ... this remains a stunning irrevelance to the fact that the XOR ... Even if the bitwise representation is not accessible any ... The algorithm will still be O. ... Then all of our XOR solutions will fail and he will ...
    (comp.programming)
  • bitwise decimal operators
    ... bitwise operators when applied to base-10 numbers. ... abstract operators AND, OR, and XOR. ... the larger digit of each pair. ... Wherever there's a 0 in the ditmask, ...
    (comp.lang.c)
  • Re: Usisng logical operators with integers in VB
    ... As well there's the Xor and Not operators. ... But as to a greater than operator that is bitwise, I actually have never heard of such a thing. ... any duplicate options set. ... Dim i As Integer ...
    (microsoft.public.dotnet.languages.vb)
  • Re: puzzle
    ... Most modern languages do support bitwise operations on integers. ... Perl has bitwise xor. ...
    (comp.programming)