Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

why is false && true = false but true || false = true?

why is

false && true = false

but

true || false = true

8 Answers

Relevance
  • ?
    Lv 6
    9 years ago
    Favorite Answer

    Its just way the "&&" operator and the "||" operators work

    if you have a statement like "if(false && true)" <- this statement will be false because in order for it to be true, both conditions in the if statement needs to be true. If one of the conditions are false, the entire if statement is false

    Here are the different scenarios for the && operator:

    false and false = false

    false and true = false

    true and false = false

    true and true = true

    And conversely, if you have a statement like "if(true || false)" <- this statement will be true because with the logical OR operator, only one condition needs to be true in order for the entire if statement to be true. It will only become false if both conditions are false

    Here are the different scenarios for the || operator:

    false or false = false

    false or true = true

    true or false = true

    true or true = true

    If you look at it in plain english, i think it will make more sense

    Here is an example

    EX #1: false && true = false

    ------------------

    FACTS:

    * I want to go to the store, but can only go if its past 5PM

    * The current time is 1PM

    >> I want to go to the store, and i can go if its past 5PM = TRUE

    >> BUT the current time is 1PM = FALSE

    So looking at the facts, will i go to the store?

    I can only go to the store if both conditions are true. If one condition is false, the entire statement is false

    So looking at the facts, I cant go to the store because its only 1PM (not 5PM), thus i will stay home, even though i really want to go to the store

    ============================

    EX #2: true || false = true

    -----------------------

    FACTS:

    * I want to buy a black or blue shirt

    * The store has no blue shirts, but they have black shirts

    >> The store has black shirts = TRUE

    >> The store doesnt have blue shirts = FALSE

    So looking at the facts, did i get what i needed?

    I was looking for a shirt (black or blue). The store didnt have any blue shirts, but they did have a black shirt, so atleast one of the conditions checked out to be true, so i left the store with a shirt

    Sometimes you need to visually paint a picture :)

  • 9 years ago

    In computer language

    && returns true only when both are true, where as || returns true if any of them is true.

    Its Truth table is

    1 acts as True & 0 acts as False

    For AND

    0 && 0 = 0

    0 && 1 = 0

    1 && 0 = 0

    1 && 1 = 1

    For OR

    0 || 0 = 0

    0 || 1 = 0

    1 || 0 = 0

    1 || 1 = 1

  • 9 years ago

    && is and. false and true will always be false.

    You need to create a truth table to see how this works.

    false and false = false

    false and true = false

    true and false = false

    true and true = true

    The same with || or.

    false or false = false

    false or true = true

    true or false = true

    true or true = true

    Have fun.

  • Anonymous
    9 years ago

    the operators &&& and || work very differently

    for &&, if one of the test condition is false then the final answer will be false irrespective of what the other conditions are.

    and for ||,if one of the test condition is true then the final answer will be true irrespective of what the other conditions are.

    you see the contradiction.

    so in your question

    for false && true,the answer is false as one of the condition is false

    but for true||false,the answer is true as one of the condition is true

  • How do you think about the answers? You can sign in to vote the answer.
  • 9 years ago

    In order for the && (AND) operator to return true both the left and right symbols must be true.

    In order for the || (OR) operator to return true, one or both of the symbols must be true.

    That's what those operators are for.

  • 5 years ago

    No

  • 9 years ago

    WHAT I don't even understand the question maybe cause umm there opposite Idk and idk how to answer that question

  • 9 years ago

    Wtf are u smoking?

Still have questions? Get your answers by asking now.