1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* complex.c (f_signbit): NaN may be signed value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2008-12-03 16:28:17 +00:00
parent ec324872d5
commit 28c53aabca
2 changed files with 13 additions and 7 deletions

View file

@ -1,3 +1,7 @@
Thu Dec 4 01:22:41 2008 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c (f_signbit): NaN may be signed value.
Wed Dec 3 23:59:32 2008 Tanaka Akira <akr@fsij.org>
* process.c (EXEC_OPTION_DUP2_CHILD): defined.

View file

@ -887,15 +887,17 @@ f_signbit(VALUE x)
switch (TYPE(x)) {
case T_FLOAT:
#ifdef HAVE_SIGNBIT
return f_boolcast(signbit(RFLOAT_VALUE(x)));
{
double f = RFLOAT_VALUE(x);
return f_boolcast(!isnan(f) && signbit(f));
}
#else
{
char s[2];
{
char s[2];
(void)snprintf(s, sizeof s, "%.0f", RFLOAT_VALUE(x));
return f_boolcast(s[0] == '-');
}
(void)snprintf(s, sizeof s, "%.0f", RFLOAT_VALUE(x));
return f_boolcast(s[0] == '-');
}
#endif
}
return f_negative_p(x);