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

Re-map a bigint from one range to another.

Similar: constrain, normalize, remap, lerp.


function remap(x, r, R, t, T)
// x: a bigint
// r: lower bound of current range
// R: upper bound of current range
// t: lower bound of target range
// T: upper bound of target range

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


xbigint.remap(25n, 0n, 100n, 0n, 1366n);
// → 341n

xbigint.remap(110n, 0n, 100n, -20n, -10n);
// → -9n


References

Clone this wiki locally