<div dir="ltr"><div>Hi Piotr,</div><div><br></div><div>2015-03-22 23:45 GMT+08:00 Piotr Caban <span dir="ltr"><<a href="mailto:piotr.caban@gmail.com" target="_blank">piotr.caban@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On 03/22/15 15:02, Kevin Chan wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>Linux and Windows treats NAN differently and I am not quite sure which I<br>should follow here, so I just leave it for now...<br></blockquote></span>The goal is to make _copysign behave as on windows. The signbit function is not available in Visual Studio.<span class=""><br></span><span class=""><br></span></blockquote><div> </div><div>Understood. Thank you :)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">    It would be nice to also change signbit definition on systems that<br>    doesn't support it, so it at least works for normal numbers.<br><br>The signbit() function is actually part of C99, not my implementation,<br>so I think it should be supported on most systems? Though I am not quite<br>sure...<br></blockquote></span>It's not available when compiled with Visual Studio. There's following code in math.c:<br>    #ifndef signbit<br>    #define signbit(x) 0<br>    #endif<br>I think it would be better if it's at least changed to something like:<br>#define signbit(x) ((x)<0 ? 1 : 0)<br>It will not work correctly for -NAN or -0 but it will not break the cases where old implementation was working.<br></blockquote></div><div><br></div><div>Sorry I didn't notice my program in VS was linked to the C++ lib for this signbit() function.<br></div><div>"#define signbit(x) ((x)<0 ? 1 : 0)"  Looks good to me, I will submit a patch. Thanks for the advice :)<br></div><br><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Maybe we could rewrite this three-line code to "(signbit(sign) &&<br>signbit(num)) ? num : -num"? It seems more efficient, but it also seems<br>the code become not very easy-to-read...<br></blockquote></span>I would stick with more readable code.<br></blockquote><div> </div><div>Great! Me, too.</div></div></div><div class="gmail_extra"><div class="gmail_quote"><br></div><div class="gmail_quote">Thanks,</div><div class="gmail_quote">Zheng</div></div></div>