Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle nan and inf in von #3170

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lua/wire/von.lua
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,14 @@ _deserialize = {
a = find(s, "[;:}~]", i)

if a then
return tonumber(sub(s, i, a - 1)) or error("vON: Number definition does not contain a valid number!"), a - 1
a = a - 1
local c = sub(s, i, a)

if c == "inf" then return math.huge, a
elseif c == "-inf" then return -math.huge, a
elseif c == "nan" then return 0/0, a end

return tonumber(c) or error("vON: Number definition does not contain a valid number!"), a
thegrb93 marked this conversation as resolved.
Show resolved Hide resolved
end

-- Using %D breaks identification of negative numbers. :(
Expand Down
Loading