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

Unable to check for NaN #134

Closed
paniq opened this issue Nov 22, 2015 · 2 comments
Closed

Unable to check for NaN #134

paniq opened this issue Nov 22, 2015 · 2 comments

Comments

@paniq
Copy link

@paniq paniq commented Nov 22, 2015

I'm unable to use the typical check for NaN (not a number) floating point numbers because s ~= s checks appear to be optimized out.

see this reproduce:

local nan = tonumber("NaN")

terra isnanf (x : float) : bool
    return x ~= x
end

terra isnan (x : double) : bool
    return x ~= x
end

-- optimized to returning false :-(
isnanf:disas()

-- pure lua test passes
assert(nan ~= nan)

-- pass
assert(isnan(1.5) == false)
-- pass
assert(isnanf(1.5) == false)
-- fail
assert(isnan(nan) == true)
-- fail
assert(isnanf(nan) == true)
@zdevito
Copy link
Collaborator

@zdevito zdevito commented Nov 23, 2015

Should be fixed by ac615b0

@zdevito zdevito closed this Nov 23, 2015
@paniq
Copy link
Author

@paniq paniq commented Nov 24, 2015

yay, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.