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 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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 Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Moderators IIYAMA Posted August 3, 2015 Author Moderators Posted August 3, 2015 thx, I will try. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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? I used to know how to code, but then I took an arrow in the knee. Project Redivivus - Remaking Old School MTA With New Code MTA 0.6 Nightly 1 released
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) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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