PostgreSQL EXP() Function
The PostgreSQL EXP() function returns e raised to the power of specified number, i.e., ex. Please note that e is the base of the natural system of logarithms, and its value is approximately 2.718282.
Syntax
EXP(x)
Parameters
x |
Required. Specify the exponent of e. |
Return Value
Returns e raised to the power of specified number.
Example 1:
The example below shows the usage of EXP() function.
SELECT EXP(0); Result: 1 SELECT EXP(1); Result: 2.718281828459045 SELECT EXP(-1); Result: 0.36787944117144233 SELECT EXP(2); Result: 7.38905609893065 SELECT EXP(-2); Result: 0.1353352832366127 SELECT LN(EXP(1)); Result: 1
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | -2 |
Data 2 | -1 |
Data 3 | 0 |
Data 4 | 1 |
Data 5 | 2 |
The statement given below can be used to calculate the exponent of records of column x.
SELECT *, EXP(x) AS EXP_Value FROM Sample;
This will produce the result as shown below:
Data | x | EXP_Value |
---|---|---|
Data 1 | -2 | 0.1353352832366127 |
Data 2 | -1 | 0.36787944117144233 |
Data 3 | 0 | 1 |
Data 4 | 1 | 2.718281828459045 |
Data 5 | 2 | 7.38905609893065 |
❮ PostgreSQL Functions