Be glad if you are not a programmer

Last Sunday I spent the whole day trying to figure out why the 64-bit version of Smia showed different results than the 32-bit version. To my big surprise, the error was due to a design decision by Microsoft.

Dynaplan Smia is developed for two versions of Microsoft Windows; the 32-bit version and the 64-bit version.

For each platform we produce a release build (for customers) and a debug build (for developers).

The table below shows the result returned by the "less than" comparison operator in C++ when applied to two concrete variables a and b.

a<b debug release
32-bit false false
64-bit false TRUE

How can it be that the 64-bit release version gives a different result than the other versions?

After isolating the problem, I searched the Internet and came across the following: NAN comparison under the 64 bit compiler is incorrect.

The IEEE standard for double precision math states the correct result of applying comparison operators to numbers. Microsoft's implementation gives the wrong results when the fast compiler option is used on 64-bit platforms.

In the above link, Microsoft even states that the wrong result is "By design".

PS
You probably wonder which values of a and b are used to produce the results shown in the table above. I tested with a=NaN and b = 1.0.
DS

Comments

Let us know what you think

You have to log in before you can comment on this article.

Please enter your account information to log in.

Notifications

Subscribe You must log in before you can subscribe to email notifications on new articles.