Unable to check for NaN #134

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

Comments

Projects
None yet
2 participants
@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

This comment has been minimized.

Show comment
Hide comment
@zdevito

zdevito Nov 23, 2015

Owner

Should be fixed by ac615b0

Owner

zdevito commented Nov 23, 2015

Should be fixed by ac615b0

@zdevito zdevito closed this Nov 23, 2015

@paniq

This comment has been minimized.

Show comment
Hide comment
@paniq

paniq Nov 24, 2015

yay, thanks

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