diff --git a/docs/BUILTINS.md b/docs/BUILTINS.md index 376f5e5..ba9dc64 100644 --- a/docs/BUILTINS.md +++ b/docs/BUILTINS.md @@ -618,4 +618,4 @@ receiver. | Name | Signature | Description | |------|-----------|-------------| -| `__borrow_guard_selftest` | `__borrow_guard_selftest of [args...]` | **Not a user builtin.** A planted fault validating the #548 borrow-scan guard: registered only in ASan builds when `EIGS_BORROW_GUARD_SELFTEST` is set, it deliberately returns a borrowed direct child past `VM_BORROW_SCAN_CAP` so the suite can prove the guard aborts loudly (naming the builtin) instead of letting a missed compensating incref become a silent use-after-free. Absent from release builds and from sanitizer builds without the opt-in env var (fuzzers must never reach a deliberate abort). | +| `__borrow_guard_selftest` | `__borrow_guard_selftest of [args...]` | **Not a user builtin.** A planted fault validating the #548 borrow-scan guard: registered only in ASan builds when `EIGS_BORROW_GUARD_SELFTEST` is set, it deliberately returns a borrowed direct child past `VM_BORROW_SCAN_CAP` so the suite can prove the guard aborts loudly (naming the builtin) instead of letting a missed compensating incref become a silent use-after-free. Absent from release builds and from sanitizer builds without the opt-in env var (fuzzers must never reach a deliberate abort). | diff --git a/docs/STDLIB.md b/docs/STDLIB.md index 9ab99b3..a337013 100644 --- a/docs/STDLIB.md +++ b/docs/STDLIB.md @@ -58,7 +58,8 @@ signature comment above each function (e.g., `# clamp of [value, lo, hi]`). | `lcm` | `lcm of [a, b]` | Least common multiple | | `argmax` | `argmax of list` | Index of the largest element (first on ties, -1 if empty) | | `argmin` | `argmin of list` | Index of the smallest element (first on ties, -1 if empty) | - +| `log2` | `log2 of x` | base-2 logarithm | +| `log10` | `log10 of x` | base-10 logarithm | ### lib/list.eigs — Functional List Operations | Function | Signature | Description | diff --git a/lib/math.eigs b/lib/math.eigs index 2457528..20cd035 100644 --- a/lib/math.eigs +++ b/lib/math.eigs @@ -135,3 +135,12 @@ define argmin(items) as: best_val is items[i] best_idx is i return best_idx + +# ---- log2: base-2 logarithm ---- +define log2(x) as: + return (log of x) / 0.6931471805599453 + +# ---- log10: base-10 logarithm ---- +define log10(x) as: + return (log of x) / 2.302585092994046 +