Physics · function
exactLog
Math.log, reproducibly: fdlibm's algorithm, which is also V8's.
Explained in Your first game, Rigid bodies.
function exactLog(x: number): numberimport { exactLog } from '@driftengine/physics';Parameters
| Parameter | Type | Description |
|---|---|---|
x | number |
In depth
Take the power of two out as k and leave a significand in [√2/2, √2), so that f = m - 1 is
small either side of zero; then log(1 + f) = f - f²/2 + s·(f²/2 + R(s²)) with s = f/(2 + f), and
k·ln 2 added back in two parts so the large part loses nothing. The exponent is read and the
significand rescaled through the double's own words — integer operations, not transcendentals.