Skip to content

Commit

Permalink
Add quantize function
Browse files Browse the repository at this point in the history
  • Loading branch information
baku89 committed Oct 4, 2023
1 parent 07aed45 commit f22b0c1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export const ceil = Math.ceil

export const floor = Math.floor

export function quantize(s: number, step: number, offset = 0): number {
return Math.round((s - offset) / step) * step + offset
}

export const min = Math.min

export const max = Math.max
Expand Down

0 comments on commit f22b0c1

Please sign in to comment.