[#38563] [Bug #1556] irb does not save history from 1.8.7-p83 and later — Nobuhiro IMAI <redmine@...>
Bug #1556: irb does not save history from 1.8.7-p83 and later
けいじゅ@いしつかです.
まつもと ゆきひろです
いまいです。
けいじゅ@いしつかです.
[#38571] [Bug #1582] IO.new Raises Other Errors between 1.8 and 1.9 — "ujihisa ." <redmine@...>
Bug #1582: IO.new Raises Other Errors between 1.8 and 1.9
チケット #1582 が更新されました。 (by Motohiro KOSAKI)
なかだです。
2010年2月27日9:43 Nobuyoshi Nakada <nobu@ruby-lang.org>:
[#38602] [Feature: trunk] rb_objspace_each_objects — SASADA Koichi <ko1@...>
ささだです.
まつもと ゆきひろです
ささだです.
ささだです.
まつもと ゆきひろです
[#38607] [Feature: trunk] GC.stat — SASADA Koichi <ko1@...>
ささだです.
In article <4A349F64.5000702@atdot.net>,
ささだです.
In article <4A3612EF.1080008@atdot.net>,
ささだです。
まつもと ゆきひろです
ささだです。
2010年10月15日16:32 SASADA Koichi <ko1@atdot.net>:
[#38608] Fixnum#fdiv — Tadayoshi Funaba <tadf@...>
Bignum#fdiv には大きな数である場合の配慮があるようですが、Fixnum ではな
fdiv では2つの異る解釈が混在しているように見えます。
まつもと ゆきひろです
> えーと、設計者は「fdivは結果がfloatになるdiv」くらいしか考え
まつもと ゆきひろです
> ふむ。「中途半端」というのはfixnumとbignumで食い違うと言う意
> > ふむ。「中途半端」というのはfixnumとbignumで食い違うと言う意
まつもと ゆきひろです
> 私が気にしているのは「挙動の理解しやすさ」ですね。
まつもと ゆきひろです
> 繰り返しになりますが、「より正確な除算」とかだと独立した実装
まつもと ゆきひろです
この件を修正しようとしていますが、
[#38609] [Feature: trunk] *_memsize() — SASADA Koichi <ko1@...>
ささだです.
[#38613] [BUG: trunk] called on terminated object — SASADA Koichi <ko1@...>
ささだです.
[#38695] [feature:trunk] let irb use pretty_inspect if possible — Yusuke ENDOH <mame@...>
遠藤です。
けいじゅ@いしつかです.
遠藤です。
けいじゅ@いしつかです.
[#38698] [Bug #1674] set_trace_func with 1line block — _ wanabe <redmine@...>
Bug #1674: set_trace_func with 1line block
[#38701] [Bug #1676] only last "return" is traced by set_trace_func — _ wanabe <redmine@...>
Bug #1676: only last "return" is traced by set_trace_func
[ruby-dev:38639] Re: Fixnum#fdiv
> えーと、設計者は「fdivは結果がfloatになるdiv」くらいしか考え
> ていませんでしたし、定義としては「Float(x)/Float(y)」を想定
> していたはずです。なんでBignumが現在のようになっているのか十
> 分に把握していないのですが。
僕もそれくらいにしか考えていませんでした。最近になって fdiv の意味に*気
が付いた*のですが、よく見るととても中途半端なんですね。
> [ruby-dev:38636]のパッチでは「Float(x/y)」を採用しておられる
> ようですが、それはこちらの方が便利なことがあると言う意味でしょ
> うか。
今はそう思っています。Float(x)/Float(y) という解釈だと略記法という意味
しかないですが、Float(x/y) はそうじゃないので。
現状では
1.fdiv(Float::MAX.to_i*2) #=> 0.0
Float::MAX.to_i.fdiv(Float::MAX.to_i*2) #=> 0.0
Rational(Float::MAX.to_i*2).fdiv(2) #=> Infinity
ですが、
1.fdiv(Float::MAX.to_i*2) #=> 2.781342323134002e-309
Float::MAX.to_i.fdiv(Float::MAX.to_i*2) #=> 0.5
Rational(Float::MAX.to_i*2).fdiv(2) #=> 1.7976931348623157e+308
となるので。
先程のパッチは、なぜか numeric.c の修正が失なわれていたので、とりあえず、
もう一度送りなおします。
Index: complex.c
===================================================================
--- complex.c (revision 23694)
+++ complex.c (working copy)
@@ -660,6 +660,7 @@
static VALUE
nucomp_fdiv(VALUE self, VALUE other)
{
+ rb_warning("Complex#fdiv will be deprecated in the future");
return nucomp_divide(self, other, f_fdiv, id_fdiv);
}
Index: numeric.c
===================================================================
--- numeric.c (revision 23694)
+++ numeric.c (working copy)
@@ -2269,6 +2269,8 @@
*
*/
+VALUE rb_big_fdiv(VALUE x, VALUE y);
+
static VALUE
fix_fdiv(VALUE x, VALUE y)
{
@@ -2277,7 +2279,7 @@
}
switch (TYPE(y)) {
case T_BIGNUM:
- return DBL2NUM((double)FIX2LONG(x) / rb_big2dbl(y));
+ return rb_big_fdiv(rb_int2big(FIX2LONG(x)), y);
case T_FLOAT:
return DBL2NUM((double)FIX2LONG(x) / RFLOAT_VALUE(y));
default:
Index: bignum.c
===================================================================
--- bignum.c (revision 23695)
+++ bignum.c (working copy)
@@ -2385,6 +2385,53 @@
return x;
}
+static VALUE
+big_fdiv(VALUE x, VALUE y)
+{
+#define DBL_BIGDIG ((DBL_MANT_DIG + BITSPERDIG) / BITSPERDIG)
+ VALUE z;
+ long l, ex, ey;
+ int i;
+
+ bigtrunc(x);
+ l = RBIGNUM_LEN(x) - 1;
+ ex = l * BITSPERDIG;
+ ex += bdigbitsize(BDIGITS(x)[l]);
+ ex -= 2 * DBL_BIGDIG * BITSPERDIG;
+ if (ex) x = big_shift(x, ex);
+
+ switch (TYPE(y)) {
+ case T_FIXNUM:
+ y = rb_int2big(FIX2LONG(y));
+ case T_BIGNUM: {
+ bigtrunc(y);
+ l = RBIGNUM_LEN(y) - 1;
+ ey = l * BITSPERDIG;
+ ey += bdigbitsize(BDIGITS(y)[l]);
+ ey -= DBL_BIGDIG * BITSPERDIG;
+ if (ey) y = big_shift(y, ey);
+ bignum:
+ bigdivrem(x, y, &z, 0);
+ l = ex - ey;
+#if SIZEOF_LONG > SIZEOF_INT
+ {
+ /* Visual C++ can't be here */
+ if (l > INT_MAX) return DBL2NUM(ruby_div0(1.0));
+ if (l < INT_MIN) return DBL2NUM(0.0);
+ }
+#endif
+ return DBL2NUM(ldexp(big2dbl(z), (int)l));
+ }
+ case T_FLOAT:
+ y = dbl2big(ldexp(frexp(RFLOAT_VALUE(y), &i), DBL_MANT_DIG));
+ ey = i - DBL_MANT_DIG;
+ goto bignum;
+ }
+ /* NOTREACHED */
+ abort();
+ return Qnil;
+}
+
/*
* call-seq:
* big.fdiv(numeric) -> float
@@ -2397,65 +2444,32 @@
*
*/
-static VALUE
+
+VALUE
rb_big_fdiv(VALUE x, VALUE y)
{
- double dx = big2dbl(x);
- double dy;
+ double dx, dy;
- if (isinf(dx)) {
-#define DBL_BIGDIG ((DBL_MANT_DIG + BITSPERDIG) / BITSPERDIG)
- VALUE z;
- long l, ex, ey;
- int i;
-
- bigtrunc(x);
- l = RBIGNUM_LEN(x) - 1;
- ex = l * BITSPERDIG;
- ex += bdigbitsize(BDIGITS(x)[l]);
- ex -= 2 * DBL_BIGDIG * BITSPERDIG;
- if (ex) x = big_shift(x, ex);
-
- switch (TYPE(y)) {
- case T_FIXNUM:
- y = rb_int2big(FIX2LONG(y));
- case T_BIGNUM: {
- bigtrunc(y);
- l = RBIGNUM_LEN(y) - 1;
- ey = l * BITSPERDIG;
- ey += bdigbitsize(BDIGITS(y)[l]);
- ey -= DBL_BIGDIG * BITSPERDIG;
- if (ey) y = big_shift(y, ey);
- bignum:
- bigdivrem(x, y, &z, 0);
- l = ex - ey;
-#if SIZEOF_LONG > SIZEOF_INT
- {
- /* Visual C++ can't be here */
- if (l > INT_MAX) return DBL2NUM(ruby_div0(1.0));
- if (l < INT_MIN) return DBL2NUM(0.0);
- }
-#endif
- return DBL2NUM(ldexp(big2dbl(z), (int)l));
- }
- case T_FLOAT:
- if (isnan(RFLOAT_VALUE(y))) return y;
- y = dbl2big(ldexp(frexp(RFLOAT_VALUE(y), &i), DBL_MANT_DIG));
- ey = i - DBL_MANT_DIG;
- goto bignum;
- }
- }
+ dx = big2dbl(x);
switch (TYPE(y)) {
case T_FIXNUM:
dy = (double)FIX2LONG(y);
+ if (isinf(dx))
+ return big_fdiv(x, y);
break;
case T_BIGNUM:
dy = rb_big2dbl(y);
+ if (isinf(dx) || isinf(dy))
+ return big_fdiv(x, y);
break;
case T_FLOAT:
dy = RFLOAT_VALUE(y);
+ if (isnan(dy))
+ return y;
+ if (isinf(dx))
+ return big_fdiv(x, y);
break;
default:
Index: rational.c
===================================================================
--- rational.c (revision 23694)
+++ rational.c (working copy)
@@ -769,7 +769,7 @@
static VALUE
nurat_fdiv(VALUE self, VALUE other)
{
- return f_div(f_to_f(self), other);
+ return f_to_f(f_div(self, other));
}
static VALUE