Skip to content
Subhajit Sahu edited this page Aug 9, 2022 · 1 revision

Linearly interpolate a bigint between two bigints.

Similar: constrain, normalize, remap, lerp.


function lerp(x, y, t)
// x: start bigint
// y: stop bigint
// t: interpolant ∈ [0, 1]

const xbigint = require('extra-bigint');


xbigint.lerp(80n, 320n, 0.8);
// → 272n

xbigint.lerp(80n, 320n, 0.20);
// → 128n

xbigint.lerp(80n, 320n, 0.32);
// → 156n


References

Clone this wiki locally