simple test

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • groups2@reenie.org

    simple test

    Why does this test as not true.

    if (!1==2) echo 'true'; else echo 'nottrue';

    It seems like it should be true.

  • Hendri Kurniawan

    #2
    Re: simple test

    groups2@reenie. org wrote:
    Why does this test as not true.
    >
    if (!1==2) echo 'true'; else echo 'nottrue';
    >
    It seems like it should be true.
    >
    IMHO Operator precedence.
    you are negating 1 instead the whole expression.

    How to negate whole expression:
    if (!(1==2)) echo 'true'; else echo 'nottrue';

    Hendri Kurniawan

    Comment

    • groups2@reenie.org

      #3
      Re: simple test

      On May 2, 12:43 am, Hendri Kurniawan <ask...@email.c omwrote:
      grou...@reenie. org wrote:
      Why does this test as not true.
      >
      if (!1==2) echo 'true'; else echo 'nottrue';
      >
      It seems like it should be true.
      >
      IMHO Operator precedence.
      you are negating 1 instead the whole expression.
      >
      How to negate whole expression:
      if (!(1==2)) echo 'true'; else echo 'nottrue';
      >
      Hendri Kurniawan
      Ok thanks. That makes sense. Or, of course,
      if (1!=2)) echo 'true'; else echo 'nottrue';

      Comment

      Working...