Udostępnij za pośrednictwem


LOG (Transact-SQL)

Returns the natural logarithm of the specified float expression.

Topic link iconTransact-SQL Syntax Conventions

Syntax

LOG ( 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.71828182845905…) is the base of natural logarithms.

The base of natural logarithms is the constant e (2.71828182845905…). LOG ( e ) = 1.0.

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

Examples

A. Calculating the logarithm for a number.

The following example calculates the LOG for the specified float expression.

DECLARE @var float
SET @var = 10
SELECT 'The LOG of the variable is: ' + CONVERT(varchar, LOG(@var))
GO

Here is the result set.

-------------------------------------
The LOG of the variable is: 2.30259

(1 row(s) affected)

B. Calculating the logarithm of the exponent of a number.

The following example calculates the LOG for the exponent of a number.

SELECT LOG (EXP (10))

Here is the result set.

----------------------------------
10
(1 row(s) affected)

See Also

Reference

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

Help and Information

Getting SQL Server 2005 Assistance