diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-03 16:28:17 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-03 16:28:17 +0000 |
commit | 28c53aabcad4ec41916ad5e72203022769ab73f5 (patch) | |
tree | f1151d8ca32b259f2d1267d048893af22c4df419 /complex.c | |
parent | ec324872d535f22c4458b3520f392c6de703aa8e (diff) | |
download | ruby-28c53aabcad4ec41916ad5e72203022769ab73f5.tar.gz |
* 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
Diffstat (limited to 'complex.c')
-rw-r--r-- | complex.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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]; - - (void)snprintf(s, sizeof s, "%.0f", RFLOAT_VALUE(x)); + { + char s[2]; - 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); |