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:04:38 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:58:19 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 @@ -2202,6 +2202,7 @@ static VALUE
2202
2202
fix_pow (x , y )
2203
2203
VALUE x , y ;
2204
2204
{
2205
+ static const double zero = 0.0 ;
2205
2206
long a = FIX2LONG (x );
2206
2207
2207
2208
if (FIXNUM_P (y )) {
@@ -2211,7 +2212,10 @@ fix_pow(x, y)
2211
2212
if (b == 0 ) return INT2FIX (1 );
2212
2213
if (b == 1 ) return x ;
2213
2214
a = FIX2LONG (x );
2214
- if (a == 0 ) return INT2FIX (0 );
2215
+ if (a == 0 ) {
2216
+ if (b > 0 ) return INT2FIX (0 );
2217
+ return rb_float_new (1.0 / zero );
2218
+ }
2215
2219
if (a == 1 ) return INT2FIX (1 );
2216
2220
if (a == -1 ) {
2217
2221
if (b % 2 == 0 )
@@ -2235,7 +2239,9 @@ fix_pow(x, y)
2235
2239
x = rb_int2big (FIX2LONG (x ));
2236
2240
return rb_big_pow (x , y );
2237
2241
case T_FLOAT :
2238
- if (a == 0 ) return rb_float_new (0.0 );
2242
+ if (a == 0 ) {
2243
+ return rb_float_new (RFLOAT (y )-> value < 0 ? (1.0 / zero ) : 0.0 );
2244
+ }
2239
2245
if (a == 1 ) return rb_float_new (1.0 );
2240
2246
return rb_float_new (pow ((double )a , RFLOAT (y )-> value ));
2241
2247
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 186
4
4
#define RUBY_RELEASE_CODE 20080608
5
- #define RUBY_PATCHLEVEL 138
5
+ #define RUBY_PATCHLEVEL 139
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