← parentheses operator page · general/parentheses/sc/addition_first
pandas ✅ · DuckDB ✅
Parentheses on scalars: (SC_1 + SC_2) * SC_3 with SC_1 = 2, SC_2 = 3 and SC_3 = 4 adds before it multiplies.
Parentheses: "For example (2+3)*4 returns 20, instead 2+3*4 returns 14 because the multiplication has higher precedence than the addition."
SC_r = 20, an Integer, as the operands are integers.
SC_r := (SC_1 + SC_2) * SC_3;
| SC_1 | SC_2 | SC_3 |
|---|---|---|
| 2 | 3 | 4 |
{
"scalars": [
{"name": "SC_1", "type": "Integer"},
{"name": "SC_2", "type": "Integer"},
{"name": "SC_3", "type": "Integer"}
]
}
{
"scalars": [
{"name": "SC_r", "type": "Integer", "value": "20"}
]
}