Single & and | are bitwise in most languages
A single & or | is a bitwise operator in C, Java and JavaScript, and in Java it is also a non-short-circuit logical operator. The parser rejects both and offers the word or the doubled symbol.
The two diagnostics are recorded below: a single & is not supported, use AND or &&; a single | is not supported, use OR or ||. The doubled symbols are accepted because across the C family they mean logical AND and OR consistently; the single ones mean something different in each language and the same thing in none of them.
In C, 5 & 2 is 0 while 5 && 2 is 1, because the bitwise operator compares bits and the integers share none. In JavaScript the single operators convert their operands to 32-bit integers, so true & true is the number 1. In Java, on two boolean values & and | are logical but evaluate both sides, which matters when the right side can throw. In Python, & and | on bool give bool, and on integers they are bitwise.
The rule for translating code is the one on the language pages: && and || map directly to AND and OR; a single & or | needs a look at the operand types before it can be mapped at all. The parser's refusal is what makes you look.
What the parser says
| You typed | Code | Why it is rejected | Repair offered |
|---|---|---|---|
| A & B | unsupported-operator | A single `&` is not supported. Use `AND` or `&&`. | Replace with AND Replace with && |
| A | B | unsupported-operator | A single `|` is not supported. Use `OR` or `||`. | Replace with OR Replace with || |
The common slip
Pasting a & b == c from C. Even if & were accepted as AND, C groups it as a & (b == c), because == binds tighter than &; two slips hide in six characters.
Questions
Why accept && but not &?
&& is logical AND in every language that has it. & is bitwise in C and JavaScript and logical-but-eager in Java; accepting it would read some programs correctly and others wrongly, silently.
Does || have the same status?
Yes: || is accepted as OR, | is rejected with the repair to OR or ||.
Related
Tools
- Logical equivalence checker: two expressions, exact verdict, counterexample
- Truth table generator: any Boolean expression, up to 12 variables, with intermediate columns
See also
- Boolean logic in C: logical vs bitwise operators
- Boolean logic in Java: &&, ||, ! vs &, | and ^
- Boolean logic in JavaScript: &&, ||, !, truthiness and precedence
- Boolean logic in Python: and, or, not, precedence and common mistakes
- ^ means XOR in C, Java and Python, not AND or power
- ~ is bitwise NOT in code, logical NOT in some textbooks
- AND gate: truth table for 2, 3 and 4 inputs, symbol and expression
- OR gate: truth table for 2, 3 and 4 inputs, inclusive or explained
Pitfalls
Generated from the Tangibool engine, semantics tangibool-semantics/1, engine 1.0.0, build . Every table, map, simplification and verdict on these pages was computed by the Tangibool engine when the site was built, and every claim was re-checked by the same exact checker the app uses. Limits are stated where they apply. © 2026 Foreranger LTD.