Re: Not = versus <>

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



Larry (and Mike and Bob)
Yeah... you're right.

The not operator inverts **everything** bitwise
(so 22 becomes -23) - I fergitted that,
and VB precedence evaluates the = first
(and THAT I should NOT have forgotten because it's so common)

Irrespective of my major boo-boo, I hope the OP realises the difference
with the two if's, and that a program could blow up if he/she uses the wrong algorithm.

Graham

Larry Serflaten wrote:
"argusy" <argusy@xxxxxxxxxxxxxxx> wrote

For the sake of clarity, lets give val and someval numbers (22 and 66)
the 'Not' before 'val' is going to evaluate the left side as "true" (-1),
because val, as 22, is regarded as "False". "Not false" equates to "True"

The statement is now
If "true" = 66 then ' and it isn't!!!


Evaluation order is known as Precedence. According to VB Help,
arithmetic operators are evaluated first, comparison operators next,
and logical operators last, so including parentheses for clarity and
adding in your values, the evaluation would have been:

If Not (22 = 66) Then .... ' True

Or

If Not (False) Then ...


HTH
LFS






.



Relevant Pages

  • Re: Linux X demo
    ... precedence to the order of evaluation. ... be related to anything such as parsing or precedence. ... THE ORDER OF EVALUATION BETWEEN SEQUENCE POINTS. ...
    (alt.lang.asm)
  • Re: Linux X demo
    ... precedence to the order of evaluation. ... evaluation of expressions is undefined. ... THE ORDER OF EVALUATION BETWEEN SEQUENCE POINTS. ...
    (alt.lang.asm)
  • Re: Article about Herb Schildt accepted at comp.risks
    ... Do you mean there is no such page, or do you mean that Microsoft's compiler allows the control of evaluation order via parentheses? ... 'Parentheses are operators that increase the precedence of the ... Precedence is about which operands are associated with which operators, whereas order of evaluation is all about the order in which things are evaluated. ...
    (comp.lang.c)
  • Re: The annotated annotated annotated C standard
    ... Because precedence is not the same as order of evaluation. ... same atomic operation, increment it, ... in your frigging standard. ...
    (comp.programming)
  • Re: Function order of execution
    ... >> I know that Delphi is supposed to work from left to right. ... >Delphi evaluates operator precedence in a left to right order if they ... Any language with infixed operators (except for restricted cases such as ... A language *could* define the order of evaluation of the entities named ...
    (borland.public.delphi.language.objectpascal)