Enhance fuzzy equality function for improved precision handling

- Updated the fuzzyEq function to utilize both absolute and relative epsilon for better precision when comparing numbers. This change improves the handling of small and large values, ensuring more accurate equality checks in the reconciliation process.
This commit is contained in:
Joe 2026-01-20 23:02:14 -06:00
parent 3c33054afd
commit d21331cb65

View file

@ -43,7 +43,12 @@ local function findDuplicateNames(children: { Instance } | { string }, virtualIn
end end
local function fuzzyEq(a: number, b: number, epsilon: number): boolean local function fuzzyEq(a: number, b: number, epsilon: number): boolean
return math.abs(a - b) < epsilon local diff = math.abs(a - b)
-- Use both absolute and relative epsilon for better precision handling
-- Absolute: for small numbers near zero
-- Relative: for larger numbers where absolute epsilon is too tight
local maxVal = math.max(math.abs(a), math.abs(b), 1)
return diff < epsilon or diff < maxVal * epsilon
end end
local function trueEquals(a, b): boolean local function trueEquals(a, b): boolean