From 0a91b021fb96dbed61ae0ad113b8bdd43a85efc0 Mon Sep 17 00:00:00 2001 From: yugui Date: Thu, 4 Dec 2008 08:55:10 +0000 Subject: merges r20473 from trunk into ruby_1_9_1. * complex.c (f_signbit): NaN may be signed value. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@20501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- complex.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'complex.c') diff --git a/complex.c b/complex.c index 95a278e3a..4230af22d 100644 --- a/complex.c +++ b/complex.c @@ -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); -- cgit