msvcrt: Fix bugs in math.c
chanchengcc at gmail.com
Sun Mar 22 09:02:49 CDT 2015
Please don't send unrelated changes in one patch, please split it into 2
Done. Thanks :)
> float CDECL MSVCRT__copysignf( float num, float sign )
>> - /* FIXME: Behaviour for Nan/Inf? */
>> - if (sign < 0.0)
>> - return num < 0.0 ? num : -num;
>> - return num < 0.0 ? -num : num;
>> + /* FIXME: Behaviour for signbit(NAN) is different in Linux and
>> + * Windows, where Windows gives a zero for -NAN
>> + */
>> + if (signbit(sign))
>> + return signbit(num) ? num : -num;
>> + return signbit(num) ? -num : num;
> Why don't you add an isnan() check? Is there any reason for returning
> "signbit(num) ? -num : num" instead of returning num?
Linux and Windows treats NAN differently and I am not quite sure which I
should follow here, so I just leave it for now...
I think the _copysignf() is supposed to return a (-num) when (num < 0 &&
sign >0), so I think this "signbit(num) ? -num : num" might be right.
> It would be nice to also change signbit definition on systems that doesn't
> support it, so it at least works for normal numbers.
The signbit() function is actually part of C99, not my implementation, so I
think it should be supported on most systems? Though I am not quite sure...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the wine-devel