Επεξεργασία

Κοινή χρήση μέσω


EXP (Transact-SQL)

Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW) SQL analytics endpoint in Microsoft Fabric Warehouse in Microsoft Fabric

Returns the exponential value of the specified float expression.

Transact-SQL syntax conventions

Syntax

EXP ( float_expression )  

Arguments

float_expression
Is an expression of type float or of a type that can be implicitly converted to float.

Return Types

float

Remarks

The constant e (2.718281...), is the base of natural logarithms.

The exponent of a number is the constant e raised to the power of the number. For example EXP(1.0) = e^1.0 = 2.71828182845905 and EXP(10) = e^10 = 22026.4657948067.

The exponential of the natural logarithm of a number is the number itself: EXP (LOG (n)) = n. And the natural logarithm of the exponential of a number is the number itself: LOG (EXP (n)) = n.

Examples

A. Finding the exponent of a number

The following example declares a variable and returns the exponential value of the specified variable (10) with a text description.

DECLARE @var FLOAT  
SET @var = 10  
SELECT 'The EXP of the variable is: ' + CONVERT(VARCHAR, EXP(@var))  
GO  

Here's the result set.

----------------------------------------------------------  
The EXP of the variable is: 22026.5  
(1 row(s) affected)  

B. Finding exponentials and natural logarithms

The following example returns the exponential value of the natural logarithm of 20 and the natural logarithm of the exponential of 20. Because these functions are inverse functions of one another, the return value in both cases is 20.

SELECT EXP(LOG(20)), LOG(EXP(20))  
GO  

Here's the result set.

---------------------- ----------------------  
20                     20  
  
(1 row(s) affected)  

Examples: Azure Synapse Analytics and Analytics Platform System (PDW)

C. Finding the exponent of a number

The following example returns the exponential value of the specified value (10).

SELECT EXP(10);  

Here's the result set.

----------  
22026.4657948067  

D. Finding exponential values and natural logarithms

The following example returns the exponential value of the natural logarithm of 20 and the natural logarithm of the exponential of 20. Because these functions are inverse functions of one another, the return value in both cases is 20.

SELECT EXP( LOG(20)), LOG( EXP(20));  

Here's the result set.

-------------- -----------------  
20                  20  

See Also

Mathematical Functions (Transact-SQL)
LOG (Transact-SQL)
LOG10 (Transact-SQL)