summaryrefslogtreecommitdiff
path: root/apps/web/src/utils/math.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/utils/math.ts')
-rw-r--r--apps/web/src/utils/math.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/apps/web/src/utils/math.ts b/apps/web/src/utils/math.ts
index ac82ca17..d45e71c0 100644
--- a/apps/web/src/utils/math.ts
+++ b/apps/web/src/utils/math.ts
@@ -10,6 +10,18 @@ export function clamp({
return Math.max(min, Math.min(max, value));
}
+export function isNearlyEqual({
+ leftValue,
+ rightValue,
+ epsilon = 0.0001,
+}: {
+ leftValue: number;
+ rightValue: number;
+ epsilon?: number;
+}): boolean {
+ return Math.abs(leftValue - rightValue) <= epsilon;
+}
+
export function evaluateMathExpression({
input,
}: {