RealDocs

UKismetMathLibrary::Log

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Returns the logarithm of A in the given base. If you want the natural log use Loge; this function is for arbitrary-base logs.

Caveats & Gotchas

  • The default value of Base is 1.0, which produces a division-by-zero (returns -inf or NaN) because log base 1 is undefined. Always pass an explicit base such as 2.0 or 10.0.
  • Passing A <= 0 returns -infinity or NaN; guard the input in gameplay code since negative values can arise from unclamped health or resource values.

Signature

static ENGINE_API double Log(double A, double Base = 1.0);

Parameters

Name Type Description Default
A double The value to compute the logarithm of.
Base double The logarithm base. Defaults to 1.0 (note: see caveat). 1.0

Return Type

double

Example

Logarithm base 2 for power-of-two calculations C++
double Value = 1024.0;
double Log2Val = UKismetMathLibrary::Log(Value, 2.0); // 10.0

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.