diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-21 10:35:50 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-21 10:35:50 +0000 |
commit | 34304a667d2560fd7477c80566f5c4c18313e49d (patch) | |
tree | e1c7250440bd700fe540ee800fe767493e5b71e7 | |
parent | 9bf9043556167cea83430f574883f4c70a99f7b1 (diff) |
merges r23742 from trunk into ruby_1_9_1.
--
* numeric.c (flo_cmp): should always return nil for NaN.
* numeric.c (flo_cmp): handle infinite value specially using
infinite? method internally. [ruby-dev:38681]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | numeric.c | 6 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 14 insertions, 1 deletions
@@ -1,3 +1,10 @@ +Fri Jun 19 17:04:59 2009 Yukihiro Matsumoto <matz@ruby-lang.org> + + * numeric.c (flo_cmp): should always return nil for NaN. + + * numeric.c (flo_cmp): handle infinite value specially using + infinite? method internally. [ruby-dev:38681] + Fri Jun 19 09:28:45 2009 Tadayoshi Funaba <tadf@dotrb.org> * numeric.c (*_numerator,*_denominator): moved to rational.c. @@ -926,6 +926,7 @@ flo_cmp(VALUE x, VALUE y) double a, b; a = RFLOAT_VALUE(x); + if (isnan(a)) return Qnil; switch (TYPE(y)) { case T_FIXNUM: b = (double)FIX2LONG(y); @@ -944,6 +945,11 @@ flo_cmp(VALUE x, VALUE y) break; default: + if (isinf(a) && (!rb_respond_to(y, rb_intern("infinite?")) || + !RTEST(rb_funcall(y, rb_intern("infinite?"), 0, 0)))) { + if (a > 0.0) return INT2FIX(1); + return INT2FIX(-1); + } return rb_num_coerce_cmp(x, y, rb_intern("<=>")); } return rb_dbl_cmp(a, b); @@ -1,6 +1,6 @@ #define RUBY_VERSION "1.9.1" #define RUBY_RELEASE_DATE "2009-05-22" -#define RUBY_PATCHLEVEL 193 +#define RUBY_PATCHLEVEL 194 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |