Skip to content
ffredyk edited this page Jul 23, 2026 · 1 revision

log

Category

Math

Arity

Unarylog <number>.

log <number>

Description

Returns the natural logarithm (base e) of a number. Input is clamped to ε (machine epsilon, ~2.22e-16) as a minimum — zero or negative inputs return a very large negative number instead of throwing. Auto-unwraps shared values.

How It Works

Calls Math.Log(max(epsilon, x)). The clamping prevents errors from zero/negative inputs. This matches the safety-oriented behavior of the SQ# math library.

Usage

log 1;                         // 0
log 2.71828;                   // ~1
log 10;                        // 2.302...

// Decay constant
_k = log 2 / _halfLife;

// Log-scale comparison
if (log _a > log _b) then { ... };  // same as a > b for positive

// Information / entropy
_entropy = -_p * log _p;

Thread Safety

ReadOnly — pure computation. Safe from any scheduler.

See Also

  • exp — natural exponential (inverse)
  • ^ — general power
  • sqrt — square root

SQ# Wiki

Home

Engine Docs

Migration

Commands

Value Constructors

Arithmetic

Comparison

Logic

Array

String

Math

Random

Type & Introspection

HashMap

Code Execution

Concurrency

Scheduler

Thread Safety

Error

Output

Time

Multiplayer

Compiler

Clone this wiki locally