Skip to content

Commit

Permalink
Make NaN similar to itself
Browse files Browse the repository at this point in the history
In Lua, NaN does not equal itself. However, it is the same value. Make NaN similar to itself to avoid recomputations.
  • Loading branch information
Aimarekin authored Oct 14, 2023
1 parent ce5ba5f commit 695637b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Utility/isSimilar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ local function isSimilar(a: any, b: any): boolean
if typeof(a) == "table" then
return false
else
return a == b
-- NaN does not equal itself but is the same
return a == b or a ~= a and b ~= b
end
end

return isSimilar
return isSimilar

0 comments on commit 695637b

Please sign in to comment.