Confused about logical statements.

  • Context: High School 
  • Thread starter Thread starter torquerotates
  • Start date Start date
  • Tags Tags
    Confused
Click For Summary
SUMMARY

The discussion centers on the interpretation of logical statements, specifically the expression "A and B or C." Participants clarify that logical operators are not strictly binary and emphasize the importance of parentheses for clarity. They highlight that different programming languages may interpret the expression differently, with some treating it as "(A and B) or C" while others interpret it as "A and (B or C)." The conversation also draws parallels between logical operations and arithmetic operations, referencing the distributive law.

PREREQUISITES
  • Understanding of logical operators in programming languages
  • Familiarity with Boolean algebra
  • Knowledge of operator precedence rules
  • Basic arithmetic concepts, including the distributive law
NEXT STEPS
  • Research logical operator precedence in Python and JavaScript
  • Learn about Boolean algebra and its applications in programming
  • Explore the use of parentheses in logical expressions for clarity
  • Study the distributive law in both arithmetic and logical contexts
USEFUL FOR

Software developers, computer science students, and anyone interested in understanding logical expressions and their interpretations in various programming languages.

torquerotates
Messages
207
Reaction score
0
A and B or C


Does that even makes sense as a statement?
I thought logical operators are binary.

Obviously, the "or" links to C but what is on the other side? A or B?

i mean 1+2-3=0 makes sense since (1+2)-3=3-3=0=1-1=1+(2-3)

But [(A and B) or C]=(AorC)and(BorC)
[ A and ( B or C) ]= (AandB)or(AandC)

these are not the same.
 
Physics news on Phys.org
Your analogy is incorrect. The corresponding expression in arithmetic would involve both multiplication and addition (distributive law). a(b+c) = ab + ac.
 
torquerotates said:
A and B or C

You really need to use parentheses to be clear


I think most computer languages will interpret it as

(A and B) or C

But I know of at least one that will make it

A and (B or C)
 

Similar threads

  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
1K
  • · Replies 30 ·
2
Replies
30
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 131 ·
5
Replies
131
Views
10K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 40 ·
2
Replies
40
Views
9K
  • · Replies 2 ·
Replies
2
Views
2K