summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-07 18:04:08 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-07 18:04:08 +0000
commit5d53d594f08e23e1efd9cd5dbbd2731bea02a1bf (patch)
tree207e0a65492c1a1e8a4e4e92a870426cf01b643a
parentaab56e10c8776dc826f53eb5589d898be04b434c (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_5@16917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--numeric.c10
-rw-r--r--version.h2
3 files changed, 13 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index d6a1f07f07a..4e5c3ce6cfc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Jun 8 03:03:27 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * numeric.c (fix_pow): returns infinity for 0**-1. [ruby-dev:32084]
+
Sun Jun 8 02:57:32 2008 James Edward Gray II <jeg2@ruby-lang.org>
Merged 13781 from trunk.
diff --git a/numeric.c b/numeric.c
index ded844a4cbd..843716cdbbf 100644
--- a/numeric.c
+++ b/numeric.c
@@ -2204,6 +2204,7 @@ static VALUE
fix_pow(x, y)
VALUE x, y;
{
+ static const double zero = 0.0;
long a = FIX2LONG(x);
if (FIXNUM_P(y)) {
@@ -2213,7 +2214,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)
@@ -2237,7 +2241,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:
diff --git a/version.h b/version.h
index 5f1c8931d0f..875b665e1d9 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2008-06-08"
#define RUBY_VERSION_CODE 185
#define RUBY_RELEASE_CODE 20080608
-#define RUBY_PATCHLEVEL 139
+#define RUBY_PATCHLEVEL 140
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8