Open In App

LN(), LOG10() AND LOG2() FUNCTION in MariaDB

Last Updated : 17 Dec, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

1. LN() Function : 
In MariaDB, the LN() function is used for the natural logarithm of a number. In this function, a number will be passed as a parameter and it will return the natural logarithm of that. The number which will be passed must be greater than 0. If the number is less than 0 or equal to 0 then it will return NULL. 

Syntax : 

LN(number)

Parameter : Required. A numeral value. 

Returns : The natural logarithm of a number. If the number is less than 0 or equal to 0 then it will return NULL. 

Example-1 : 

SELECT LN(2);

Output :  

0.6931471805599453

Example-2 :  

SELECT (LN(2.7)+LN(2.7));

Output :  

2

Example-3 :  

SELECT LN(-10);

Output :  

NULL

2. LOG10() Function : 
In MariaDB, the LOG10 function used for returns the base-10 logarithm of a number. In this function, a number will be passed as a parameter and it will return the base-10 logarithm of a number. The number which will be passed must be greater than 0. If the number is less than 0 or equal to 0 then it will return NULL. 

Syntax : 

LOG10(number)

Parameter : Required. A numeral value. 

Returns : The base-10 logarithm of a number. If the number is less than 0 or equal to 0 then it will return NULL. 

Example-1 :  

SELECT (LOG10(100)-LOG(10));

Output :  

1

Example-2 :  

SELECT LOG10(0.7);

Output :  

-0.154901959985

Example-3 :  

SELECT LOG10(-9.7);

Output :  

NULL

3. LOG2() Function : 
In MariaDB, the LOG2 function used for returns the base-2 logarithm of a number. In this function, a number will be passed as a parameter and it will return the base-2 logarithm of a number. The number which will be passed must be greater than 0. If the number is less than 0 or equal to 0 then it will return NULL. 

Syntax : 

LOG2(number)

Parameter : Required. A numeral value. 

Returns : The base-2 logarithm of a number. If the number is less than 0 or equal to 0 then it will return NULL. 

Example-1 : 

SELECT (LOG2(32)*LOG2(4));

Output :  

10

Example-2 :  

SELECT LOG2(8);

Output :  

3

Example-3 :  

SELECT LOG2(0);

Output :  

NULL

 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads