Skip to main content

Dev & Computing · 布尔代数(Boolean Algebra) · Updated 2026-10-25

What Is Boolean Algebra?

Definition

Boolean algebra over 0/1: AND (·, true only if all true), OR (+, true if any true), NOT (', inversion). Key laws: distribution A·(B+C)=A·B+A·C, De Morgan (A·B)'=A'+B', absorption A+A·B=A. In code: && multiplies, || adds, ! inverts. De Morgan in prose: "not (A and B)" equals "not A or not B" — if(!(isVip && hasCoupon)) is exactly if(!isVip || !hasCoupon). Short-circuit evaluation is its engineering form: in A&&B, a false A skips B entirely.

Formula

(A·B)' = A' + B'; (A+B)' = A' · B'

Worked Example

In if (user && user.isAdmin && user.active), a null user short-circuits the chain — null-pointer exceptions dodged by boolean algebra.

Common Misconception

"Both sides of A||B always run" — short-circuiting skips B when A is true (side effects vanish). !(A&&B) does not equal !A && !B — it equals !A || !B; flipping De Morgan's direction is a classic logic bug.

Matching Calculators

Related Terms

Keep Exploring

Browse the full glossary, or head back to the homepage for 1,435 free online calculators.

Back to glossary