[Kde-games-devel] KPat broken for Windows

Parker Coates parker.coates at gmail.com
Mon Aug 17 19:25:39 CEST 2009


On Mon, Aug 17, 2009 at 12:28, Casper van Donderen wrote:
> ------Original Message------
> From: Parker Coates
> To: KDE games development
> ReplyTo: KDE games development
> Subject: Re: [Kde-games-devel] KPat broken for Windows
> Sent: Aug 17, 2009 18:14
>
>> On Mon, Aug 17, 2009 at 09:40, Casper van Donderen wrote:
>>> signbit() is not available in BSD & (MSVC) Windows. it is not
>>> available in math.h on Windows.
>>
>> Hmm. That's interesting. On such platforms, how does one determine the
>> sign of a floating point number with proper handling of -0.0? In most
>> situations "n >= 0.0" is enough, but that returns true if n is -0.0.
>>
>>> Please use another solution for this....
>>
>> Fortunately for us, the code in question can probably get by without
>> properly handling -0.0 (although it would be nice if it could), so I
>> replaced the conditions with simple comparisons. See
>> http://websvn.kde.org/?view=rev&revision=1012405 .
>>
>> Parker
>
> Haha,
>
> I just tested for you:
> Float test = -0.0f;
>
> That returns as -0 with cout and is smaller than 0.
>
> MSVC2008.

Hmm. The plot thickens. On gcc 4.3.2 I get the following:

(-0.0 == 0.0) = true
(-0.0 <= 0.0) = true
(-0.0 < 0.0) = false

It looks like MSVC isn't following IEEE754
(http://en.wikipedia.org/wiki/Signed_zero#Comparisons).

Parker


More information about the kde-games-devel mailing list