ID:2010793
 
BYOND Version:509
Operating System:Linux
Web Browser:Chrome 47.0.2526.106
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
Descriptive Problem Summary: Attempting to use a 1.#IND or -1.#IND literal results in zero.

Numbered Steps to Reproduce Problem:
Use 1.#IND or -1.#IND as a literal.
Receive zero.

Code Snippet (if applicable) to Reproduce Problem:
/world/New()
var/nan = -(1.#INF/1.#INF) // make a true NaN value
world.log << nan // "1.#IND", or "nan" on Linux
world.log << 1.#IND // "0"
world.log << (nan == 0) // "0" (false)
world.log << (nan == 1.#IND) // "0" (false)
world.log << (nan == nan) // "0" (false)
world.log << (1.#IND == 0) // "1" (true)
world.log << (1.#IND == 1.#IND) // "1" (true)


Expected Results:
NaN literals would produce a NaN value when used; above code would print:

1.#IND
1.#IND
0
0
0
0
0


Actual Results:
NaN literals produce zero; above code prints:

1.#IND
0
0
0
0
1
1


Does the problem occur:
Every time? Or how often? Every time
In other games? N/A
In other user accounts? Unknown
On other computers? Yes

When does the problem NOT occur? Unknown

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? Unknown.

Workarounds: Don't use NaN literals?
It's kind of funky; those literals aren't really BYOND things; they're OS things. I wonder if the compile-time optimization is fucking things up.

    var nan = -(1.#INF/1.#INF)


This is actually giving me a value of 1.#QNAN which is new - I thought that only happened on Windows 8 or 10; I'm running Win7.

    var nan = 1.#INF-1.#INF


This gives me -1.#NAN though, but it's still not equal to the compile time -1.#NAN.
I get the same results running DD in Wine, yeah. -(inf/inf) is 1.#QNAN, and inf-inf is -1.#IND. They're just 'nan' and '-nan' on Linux.
There's some code that compares a number to -0 on output to see if it should be 0 instead, and somehow NaN is matching -0. I put in a fix for the JSON stuff, and that may as well go in a maintenance release if I do one.

However it doesn't appear to fix this issue at all. From what I'm seeing, by default the compiler is using a quicker form of comparison that's causing this issue. I'll have to look into this further at some point and see if there's a way to selectively disable that, not just for Windows but also for Linux.