Logo

FACTLN

Updated 2023-10-27 16:06:16.793000

Syntax

SELECT [westclintech].[wct].[FACTLN] (
   <@Number, float,>)

Description

Use the scalar function FACTLN to calculate the natural logarithm of a factorial. It can be useful to have the natural logarithm available because the limits of the float data type in SQL Server limit the maximum value of a factorial to 171! The natural logarithm can be substituted in many calculations; just remember to use the EXP() function on the final result.

Arguments

@Number

is the value to be evaluated by the function. @Number is an expression of type float or of a type that can be implicitly converted to float.

Return Type

float

Remarks

If @Number < 0, FACTLN returns an error.

@Number is truncated to zero decimal places.

Examples

SELECT wct.FACTLN(5);

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"4.78749174278205"}]}
SELECT EXP(wct.FACTLN(200) - wct.FACTLN(175));

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"7.01372425899837E+56"}]}