From: EGUCHI Osamu Date: 1999-02-10T02:08:53+09:00 Subject: [ruby-dev:4942] [FIX] numeric.c (Re: Ruby 1.3.1-990209) えぐち@エスアンドイー です。 numeric.c に対するパッチです。 内容は、 + (5 * 1).type => Bignum になる問題の fix + FreeBSD での浮動小数点例外のマスクの設定を、 他のOSに近くした。 です。 えぐち p.s. 123 ** nil => 1 って言うのは不思議ですね。 nil as zero と言えば、言えなくもないけど。 123.4 ** nil -> `**': nil can't be coerced into Float (TypeError) なので、同じにした方が良いかとも思います。 ...特に、問題は生じていません。 --- ..//ruby-1.3.1-990209/numeric.c Tue Feb 9 15:08:21 1999 +++ numeric.c Wed Feb 10 01:42:41 1999 @@ -13,6 +13,9 @@ #include "ruby.h" #include #include +#ifdef __FreeBSD__ +#include +#endif static ID coerce; static ID to_i; @@ -985,6 +988,7 @@ b = FIX2LONG(y); if (b == 0) return INT2FIX(1); + if (b == 1) return x; a = FIX2LONG(x); if (b > 0) { return rb_big_pow(rb_int2big(a), y); @@ -1402,6 +1406,10 @@ void Init_Numeric() { +#ifdef __FreeBSD__ + /* allow divide by zero -- Inf */ + fpsetmask(fpgetmask() & ~(FP_X_DZ|FP_X_INV)); +#endif coerce = rb_intern("coerce"); to_i = rb_intern("to_i");