API Reference › Math › Math.log
method

Math.log

Math.log(x) -> fixed

Returns the natural logarithm ln(x) for x > 0, computed in Q16.16 from a deterministic integer log₂ (bit-scan for the exponent, a short series for the mantissa) scaled by ln 2 — bit-identical on every platform. It is the inverse of Math.exp: reach for it to turn multiplicative growth into a straight line — score-to-level curves, logarithmic difficulty, decibel-style volume. Non-positive inputs are out of domain and saturate to a large negative value rather than returning a meaningful number.

Example

program Demo {
  handler Step phase Update {
    let level = Math.floor(Math.log(score))   # diminishing returns on score
  }
}
← All symbols