File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change
1
+ Sun Jun 8 03:03:27 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
2
+
3
+ * numeric.c (fix_pow): returns infinity for 0**-1. [ruby-dev:32084]
4
+
1
5
Sun Jun 8 02:57:32 2008 James Edward Gray II <jeg2@ruby-lang.org>
2
6
3
7
Merged 13781 from trunk.
Original file line number Diff line number Diff line change @@ -2204,6 +2204,7 @@ static VALUE
2204
2204
fix_pow (x , y )
2205
2205
VALUE x , y ;
2206
2206
{
2207
+ static const double zero = 0.0 ;
2207
2208
long a = FIX2LONG (x );
2208
2209
2209
2210
if (FIXNUM_P (y )) {
@@ -2213,7 +2214,10 @@ fix_pow(x, y)
2213
2214
if (b == 0 ) return INT2FIX (1 );
2214
2215
if (b == 1 ) return x ;
2215
2216
a = FIX2LONG (x );
2216
- if (a == 0 ) return INT2FIX (0 );
2217
+ if (a == 0 ) {
2218
+ if (b > 0 ) return INT2FIX (0 );
2219
+ return rb_float_new (1.0 / zero );
2220
+ }
2217
2221
if (a == 1 ) return INT2FIX (1 );
2218
2222
if (a == -1 ) {
2219
2223
if (b % 2 == 0 )
@@ -2237,7 +2241,9 @@ fix_pow(x, y)
2237
2241
x = rb_int2big (FIX2LONG (x ));
2238
2242
return rb_big_pow (x , y );
2239
2243
case T_FLOAT :
2240
- if (a == 0 ) return rb_float_new (0.0 );
2244
+ if (a == 0 ) {
2245
+ return rb_float_new (RFLOAT (y )-> value < 0 ? (1.0 / zero ) : 0.0 );
2246
+ }
2241
2247
if (a == 1 ) return rb_float_new (1.0 );
2242
2248
return rb_float_new (pow ((double )a , RFLOAT (y )-> value ));
2243
2249
default :
Original file line number Diff line number Diff line change 2
2
#define RUBY_RELEASE_DATE "2008-06-08"
3
3
#define RUBY_VERSION_CODE 185
4
4
#define RUBY_RELEASE_CODE 20080608
5
- #define RUBY_PATCHLEVEL 139
5
+ #define RUBY_PATCHLEVEL 140
6
6
7
7
#define RUBY_VERSION_MAJOR 1
8
8
#define RUBY_VERSION_MINOR 8
You can’t perform that action at this time.
0 commit comments