diff --git a/packages/math/src/prec.ts b/packages/math/src/prec.ts index bfab3adfcb..bcd94d6aca 100644 --- a/packages/math/src/prec.ts +++ b/packages/math/src/prec.ts @@ -15,6 +15,10 @@ export const trunc: FnN = (x) => (x < 0 ? Math.ceil(x) : Math.floor(x)); export const roundTo = (x: number, prec = 1) => Math.round(x / prec) * prec; +export const floorTo = (x: number, prec = 1) => Math.floor(x / prec) * prec; + +export const ceilTo = (x: number, prec = 1) => Math.ceil(x / prec) * prec; + /** * Only rounds `x` to nearest int if `fract(x)` <= `eps` or >= `1-eps`. *