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
f1 := LOG(10, 100E0), -- Log base 10 with integer base
f2 := LOG(10, 1000E0), -- Another log base 10
f3 := LOG(2, 8E0), -- Log base 2
f4 := LOG(2, 16E0), -- Log base 2 of 16
f5 := LOG(10E0, 100E0), -- Floating-point base also accepted
f6 := LOG(10, 1E0) -- Log of 1 is always 0
;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