Reputation: 727
There are log10 and ln function in manual, but can not find how to compute log2 anymore ..
https://docs.aws.amazon.com/redshift/latest/dg/Math_functions.html
Upvotes: 3
Views: 1015
Reputation: 48865
Per math classes in high school:
log2(n) ::= log10(n) / log10(2)
any base will do. You can do it with base e too, as in:
log2(n) ::= ln(n) / ln(2)
Upvotes: 3
Reputation: 1270893
The log in any base can be calculated by division. For this particular case:
select ln(x) / ln(2)
Upvotes: 7