1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 10:54:44 +00:00

feat(core/stdlib): implement LinkedList, PriorityQueue, and Queue data structures

This commit is contained in:
2026-02-15 02:36:41 +07:00
parent 09fe8079c0
commit 7b5da22290
37 changed files with 4532 additions and 14 deletions

View File

@@ -1,3 +1,10 @@
/**
* Precision scale for bigint interpolation (6 decimal places).
* BigInt has no overflow, so higher precision is free.
*/
const SCALE = 1_000_000;
const SCALE_N = BigInt(SCALE);
/**
* @name lerpBigInt
* @category Math
@@ -11,7 +18,7 @@
* @since 0.0.2
*/
export function lerpBigInt(start: bigint, end: bigint, t: number) {
return start + ((end - start) * BigInt(t * 10000)) / 10000n;
return start + ((end - start) * BigInt(Math.round(t * SCALE))) / SCALE_N;
}
/**
@@ -27,5 +34,5 @@ export function lerpBigInt(start: bigint, end: bigint, t: number) {
* @since 0.0.2
*/
export function inverseLerpBigInt(start: bigint, end: bigint, value: bigint) {
return start === end ? 0 : Number((value - start) * 10000n / (end - start)) / 10000;
return start === end ? 0 : Number((value - start) * SCALE_N / (end - start)) / SCALE;
}