folly::constexpr_log

constexpr_log

Synopsis

Declared in <folly/ConstexprMath.h>

template<typename T>
requires std::floating_point<T>
constexpr
T
constexpr_log(T const num);

Description

Calculates an approximation of the natural logarithm ln(num).

The implementation uses a quickly-converging, high-precision iterative technique as described in: https://en.wikipedia.org/wiki/Natural_logarithm#High_precision

The technique works best with numbers that are close enough to 1, so the implementation uses a quick shrink/growth technique as described in: https://en.wikipedia.org/wiki/Natural_logarithm#Efficient_computation

Return Value

An approximation of the natural logarithm of num.

Parameters

NameDescription
numThe value whose natural logarithm is computed.