SQLite exp() Function

Summary: in this tutorial, you will learn how to use the SQLite exp() function to calculate the e (Euler’s number) raised to the power of a number.

Introduction to SQLite exp() function

The exp() function allows you to compute e raise to the power of a specified number.

The following shows the syntax for the exp() function:

exp(x)Code language: SQL (Structured Query Language) (sql)

In this syntax:

  • The x is a number that you want to compute e raised to its power.

The exp() function returns ex where e is approximately equal to 2.71828182845905. The function returns NULL if x is NULL.

SQLite exp() function examples

Let’s explore some examples of using the exp() function.

1) Basic exp() function examples

The following statement uses the exp() function to compute the exponential value of 1:

SELECT exp(1) result;Code language: SQL (Structured Query Language) (sql)

Output:

result
-----------------
2.718281828459045Code language: SQL (Structured Query Language) (sql)

The following example uses the exp() function to calculate the exponential value of 2:

SELECT exp(2) result;Code language: SQL (Structured Query Language) (sql)

Output:

result
----------------
7.38905609893065Code language: SQL (Structured Query Language) (sql)

2) Using exp() function with negative power

The following example uses the exp() function with a negative power:

SELECT exp(-1) result;

Output:

result
-------------------
0.36787944117144233Code language: CSS (css)

Summary

  • Use the exp() function to compute e raised to the power of a number.
Was this tutorial helpful ?