OR and AND without parenthesis

Discussion in 'Java' started by IveCal, Jun 22, 2007.

  1. IveCal

    IveCal Guest

    Hello, I have a question.
    assuming, all letters below are either true or false.
    Are the following the same:
    1. (A OR B) && (C) && (D OR E OR F OR G OR H)
    2. A OR B && C && D OR E OR F OR G OR H
    IveCal, Jun 22, 2007
    #1
    1. Advertising

  2. IveCal wrote:
    > Hello, I have a question.
    > assuming, all letters below are either true or false.
    > Are the following the same:
    > 1. (A OR B) && (C) && (D OR E OR F OR G OR H)
    > 2. A OR B && C && D OR E OR F OR G OR H


    There is no OR in Java. Assuming that you mean ||, no, they are not the same,
    just as:

    (a + b) * (c) * (d + e + f + g + h)

    is not the same as:

    a + b * c * d + e + f + g + h


    --
    John W. Kennedy
    "Only an idiot fights a war on two fronts. Only the heir to the throne of the
    kingdom of idiots would fight a war on twelve fronts"
    -- J. Michael Straczynski. "Babylon 5", "Ceremonies of Light and Dark"
    John W. Kennedy, Jun 22, 2007
    #2
    1. Advertising

  3. hi

    the equation are not the same , they will generate different outputs
    the execution sequence will be () --> and --> or

    think of it as a numerical equation



    On Jun 21, 10:39 pm, IveCal <> wrote:
    > Hello, I have a question.
    > assuming, all letters below are either true or false.
    > Are the following the same:
    > 1. (A OR B) && (C) && (D OR E OR F OR G OR H)
    > 2. A OR B && C && D OR E OR F OR G OR H
    George N. Morcos, Jun 22, 2007
    #3
  4. IveCal

    Roedy Green Guest

    On Fri, 22 Jun 2007 02:39:50 -0000, IveCal <> wrote,
    quoted or indirectly quoted someone who said :

    >Hello, I have a question.
    >assuming, all letters below are either true or false.
    >Are the following the same:
    >1. (A OR B) && (C) && (D OR E OR F OR G OR H)
    >2. A OR B && C && D OR E OR F OR G OR H


    There are three things you need to understand to solve problems of
    this class:

    1. the difference between the two flavours of or | and ||. see
    http://mindprod.com/jgloss/boolean.html

    2. the difference between the two flavours of or & and &&

    3. the precedence table. See
    http://mindprod.com/jgloss/precedence.html
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Jun 22, 2007
    #4
  5. IveCal

    stefanomnn Guest

    > There is no OR in Java. Assuming that you mean ||, no, they are not the same,
    > just as:
    >
    > (a + b) * (c) * (d + e + f + g + h)
    >
    > is not the same as:
    >
    > a + b * c * d + e + f + g + h
    >
    > --
    > John W. Kennedy
    > "Only an idiot fights a war on two fronts. Only the heir to the throne of the
    > kingdom of idiots would fight a war on twelve fronts"
    > -- J. Michael Straczynski. "Babylon 5", "Ceremonies of Light and Dark"


    wonderful answare!
    stefanomnn, Jun 22, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. effbiae

    preprocessor and parenthesis

    effbiae, Feb 6, 2006, in forum: C Programming
    Replies:
    5
    Views:
    339
    Jordan Abel
    Feb 7, 2006
  2. Howard Bryce

    sizeof without parenthesis

    Howard Bryce, Oct 2, 2006, in forum: C Programming
    Replies:
    28
    Views:
    1,427
    Dave Thompson
    Oct 16, 2006
  3. hakunin
    Replies:
    30
    Views:
    394
    Dave Bass
    Jun 19, 2008
  4. Daniel Fac
    Replies:
    3
    Views:
    139
    Daniel Fac
    Nov 2, 2008
  5. Carl Cunningham

    Regular expressions and parenthesis in match text

    Carl Cunningham, Sep 15, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    113
    Carl Cunningham
    Sep 15, 2003
Loading...

Share This Page