LOG()
All functions > MATH > LOG()
Returns the logarithm of a number to a specified base.
Signatures
Logarithm
Returns: Logarithm of number to base base
LOG(base: B, number: T) → DOUBLE sql
| Parameter | Type | Required | Description |
|---|---|---|---|
base | B | Yes | Base of the logarithm; integer or floating-point |
number | T | Yes | Positive floating-point number |
With:
B: Integer or floating-pointT: Floating-point type (FLOAT, DOUBLE)
Signature notes:
- The base may be an integer (e.g.
LOG(2, x),LOG(10, x)) or a floating-point number - The number argument must be floating-point; cast integers explicitly if needed
- Both base and number must be positive, and the base must not be 1
LOG(base, 1.0) = 0for any valid base- Returns NULL if any input is NULL
Examples
FeatureQL
SELECT
-- Log base 10 with integer base
f1 := LOG(10, 100e0),
-- Another log base 10
f2 := LOG(10, 1000e0),
-- Log base 2
f3 := LOG(2, 8e0),
-- Log base 2 of 16
f4 := LOG(2, 16e0),
-- Floating-point base also accepted
f5 := LOG(10e0, 100e0),
-- Log of 1 is always 0
f6 := LOG(10, 1e0)
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR | f5 VARCHAR | f6 VARCHAR |
|---|---|---|---|---|---|
| 2.0 | 3.0 | 3.0 | 4.0 | 2.0 | 0.0 |
On this page