Moderators IIYAMA Posted August 2, 2015 Moderators Posted August 2, 2015 What is the best way to detect a NaN value? I found this: (but it doesn't seems to work, I still get warnings in the rest of the code when I check it like that) function isnan(x) return x ~= x end
GTX Posted August 2, 2015 Posted August 2, 2015 This should work fine. -- Source: [url=http://stackoverflow.com/questions/12102222/how-to-test-for-1-ind-indeterminate-in-lua#answer-12103118]http://stackoverflow.com/questions/1210 ... r-12103118[/url] local function isnan(x) if (x ~= x) then return true end if type(x) ~= "number" then return false end if tostring(x) == tostring((-1)^0.5) then return true end return false end
ixjf Posted August 4, 2015 Posted August 4, 2015 What is it for? Are you sure you shouldn't be validating the input, rather than working around bad output?
Moderators IIYAMA Posted August 5, 2015 Author Moderators Posted August 5, 2015 This function returns somtimes NaN https://wiki.multitheftauto.com/wiki/Ge ... ldPosition in combination with https://wiki.multitheftauto.com/wiki/GetPedTargetEnd There is not much I can do about it Afaik. Also I get sometimes NaN values when I am playing around with vectors of my serverside bullet collision system. (checking the distance between 2 lines in 3D)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now