Arithmetic multiplication operator *
Last updated: 2026-11-04
Arithmetic multiplication operator *
The multiplication operator * multiplies two numeric operands and is the usual way to compute amount times quantity. It applies to integer, numeric, double precision and other numeric types, and numeric multiplication keeps the scale of the result. A NULL operand yields a NULL result.
| Kind | operator |
|---|---|
| Example Language | SQL |
📝 Syntax
a * b
Precedence: `*` sits at the same level as `/` and `%`, above binary `+ -` and below `^`; operators at the same level are left-associative, so `2 * 3 + 4 * 5` evaluates the multiplications first and gives 26. Division and modulo share that level and are also left-associative (`10 / 4 * 2` is 4, not 5).
⚙️ Parameters
| a | Left operand, numeric; if NULL the result is NULL. |
|---|---|
| b | Right operand, numeric; if NULL the result is NULL. |
Returns:A numeric value; NULL if either operand is NULL.
▶ Example
Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.
Output:
SELECT id, price, qty, price * qty AS amount FROM t_mul ORDER BY id
id | price | qty | amount
---+-------+------+-------
1 | 19.90 | 3 | 59.70
2 | 19.90 | NULL | NULL
(2 rows)
SELECT price * qty IS NULL AS null_is_absent FROM t_mul WHERE id = 2
null_is_absent
--------------
true
(1 row)
📌 Key Points
- NULL propagation: the product is NULL if either the price or the quantity is NULL.
- numeric keeps its scale: 19.90 * 3 gives 59.70 rather than 59.7, which keeps money reconciliation exact.
- numeric multiplication may produce more decimal places than the inputs, so compare with `=` rather than as text.
💡 Related Cases
More case studies coming soon.
📚 Related Reference
❓ FAQ
QDo floating point multiplications lose precision?
AYes. real and double precision are binary floats, so 0.1*3 can yield 0.30000000000000004. Use numeric, or store money as integer cents, for financial calculations.