Definitely a repost, but it fits the season

  • Lifter
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    Is there a standard order of operations for boolean logic, such as PEMDAS is for arithmetic?

    • Captain Aggravated@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 months ago

      That’s an interesting question, and I’m gonna go learn the answer.

      duckduckgo powers activate!

      So yes, they do. It generally goes NOT, AND, OR. And if you’re doing algebra in binary and you’ve got boolean operators in there (you can AND two numbers the same way you can ADD two numbers in binary) PEMDAS becomes PEMDASNAO.

      • Lifter
        link
        fedilink
        arrow-up
        1
        ·
        3 months ago

        Nice, so my gut feeling about not needing the parenthesis above was right.

          • silasmariner@programming.dev
            link
            fedilink
            arrow-up
            1
            ·
            3 months ago

            It’s a reasonable convention that matches the common DNF (disjunctive normal form) of propositional logic, can confirm it’s the right read.

            I’d still probably use parentheses for the ∧ (and/conjunction), though I’d never bother with it for ¬ (negation)