diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-07 18:05:03 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-07 18:05:03 +0000 |
commit | 24a9bf988c896f073d0d483a117c4197f93006c2 (patch) | |
tree | da8705223870f368ade237a07eeedf57d1da63e5 | |
parent | b940547cb9c9a5d29f72ad2683e8868bc389c5e1 (diff) |
merge revision(s) 13785:
* numeric.c (fix_pow): returns infinity for 0**-1. [ruby-dev:32084]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@16919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | numeric.c | 10 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 13 insertions, 3 deletions
@@ -1,3 +1,7 @@ +Sun Jun 8 03:04:38 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * numeric.c (fix_pow): returns infinity for 0**-1. [ruby-dev:32084] + Sun Jun 8 02:58:19 2008 James Edward Gray II <jeg2@ruby-lang.org> Merged 13781 from trunk. @@ -2202,6 +2202,7 @@ static VALUE fix_pow(x, y) VALUE x, y; { + static const double zero = 0.0; long a = FIX2LONG(x); if (FIXNUM_P(y)) { @@ -2211,7 +2212,10 @@ fix_pow(x, y) if (b == 0) return INT2FIX(1); if (b == 1) return x; a = FIX2LONG(x); - if (a == 0) return INT2FIX(0); + if (a == 0) { + if (b > 0) return INT2FIX(0); + return rb_float_new(1.0 / zero); + } if (a == 1) return INT2FIX(1); if (a == -1) { if (b % 2 == 0) @@ -2235,7 +2239,9 @@ fix_pow(x, y) x = rb_int2big(FIX2LONG(x)); return rb_big_pow(x, y); case T_FLOAT: - if (a == 0) return rb_float_new(0.0); + if (a == 0) { + return rb_float_new(RFLOAT(y)->value < 0 ? (1.0 / zero) : 0.0); + } if (a == 1) return rb_float_new(1.0); return rb_float_new(pow((double)a, RFLOAT(y)->value)); default: @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2008-06-08" #define RUBY_VERSION_CODE 186 #define RUBY_RELEASE_CODE 20080608 -#define RUBY_PATCHLEVEL 138 +#define RUBY_PATCHLEVEL 139 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 |