[#28501] rb_gc_call_finalizer_at_exit() の実行中かどうかを知りたい — Hidetoshi NAGAI <nagai@...>
永井@知能.九工大です.
6 messages
2006/04/03
[#28502] Re: rb_gc_call_finalizer_at_exit() の実行中かどうかを知りたい
— Yukihiro Matsumoto <matz@...>
2006/04/03
まつもと ゆきひろです
[#28509] Rational — Tadayoshi Funaba <tadf@...>
ふなばです。
49 messages
2006/04/05
[#28510] Re: Rational
— keiju@... (石塚圭樹)
2006/04/05
けいじゅ@いしつかです.
[#28512] Re: Rational
— Tadayoshi Funaba <tadf@...>
2006/04/05
ふなばです。
[#28515] Re: Rational
— keiju@... (石塚圭樹)
2006/04/05
けいじゅ@いしつかです.
[#28522] Re: Rational
— Tadayoshi Funaba <tadf@...>
2006/04/06
ふなばです。
[#28523] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/06
まつもと ゆきひろです
[#28526] Re: Rational
— Tadayoshi Funaba <tadf@...>
2006/04/06
ふなばです。
[#28530] Re: Rational
— Tadayoshi Funaba <tadf@...>
2006/04/09
ふなばです。
[#28513] Re: Rational
— Shin-ichiro HARA <sinara@...>
2006/04/05
原です。
[#28514] Re: Rational
— keiju@... (石塚圭樹)
2006/04/05
けいじゅ@いしつかです.
[#28517] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/06
まつもと ゆきひろです
[#28520] Re: Rational
— keiju@... (石塚圭樹)
2006/04/06
けいじゅ@いしつかです.
[#28521] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/06
まつもと ゆきひろです
[#28525] Re: Rational
— keiju@... (石塚圭樹)
2006/04/06
けいじゅ@いしつかです.
[#28527] Re: Rational
— Shin-ichiro HARA <sinara@...>
2006/04/06
原です。
[#28536] Re: Rational
— Shin-ichiro HARA <sinara@...>
2006/04/10
原です。
[#28537] Re: Rational
— keiju@... (石塚圭樹)
2006/04/10
けいじゅ@いしつかです.
[#28545] Re: Rational
— Shin-ichiro HARA <sinara@...>
2006/04/11
原です。
[#28546] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/11
まつもと ゆきひろです
[#28547] Re: Rational
— keiju@... (石塚圭樹)
2006/04/11
けいじゅ@いしつかです.
[#28548] Re: Rational
— Yukihiro Matsumoto <matz@...>
2006/04/11
まつもと ゆきひろです
[#28563] Proxy authentication patches for open-uri and rubygems — "Tadashi Kadowaki" <tadakado@...>
門脇と申します。
3 messages
2006/04/15
[#28569] rational 1.01 — Shin-ichiro HARA <sinara@...>
原です。
16 messages
2006/04/16
[#28571] Re: rational 1.01
— Tadayoshi Funaba <tadf@...>
2006/04/16
ふなばです。
[#28572] Re: rational 1.01
— Shin-ichiro HARA <sinara@...>
2006/04/16
原です。
[#28573] Re: rational 1.01
— Tadayoshi Funaba <tadf@...>
2006/04/16
ふなばです。
[#28574] Re: rational 1.01
— Shin-ichiro HARA <sinara@...>
2006/04/16
原です。
[#28575] Re: rational 1.01
— Shin-ichiro HARA <sinara@...>
2006/04/17
原です。
[#28576] Re: rational 1.01
— Tadayoshi Funaba <tadf@...>
2006/04/17
ふなばです。
[#28578] Re: rational 1.01
— Tadayoshi Funaba <tadf@...>
2006/04/17
ふなばです。
[#28584] Re: rational 1.01
— Shin-ichiro HARA <sinara@...>
2006/04/18
原です。
[#28589] Float#div and Float#divmod [AGAIN] — Shin-ichiro HARA <sinara@...>
原です。
16 messages
2006/04/23
[#28590] Re: Float#div and Float#divmod [AGAIN]
— Yukihiro Matsumoto <matz@...>
2006/04/23
まつもと ゆきひろです
[#28591] Re: Float#div and Float#divmod [AGAIN]
— Shin-ichiro HARA <sinara@...>
2006/04/23
[#28592] Re: Float#div and Float#divmod [AGAIN]
— Yukihiro Matsumoto <matz@...>
2006/04/23
まつもと ゆきひろです
[ruby-dev:28609] Re: Float#div and Float#divmod [AGAIN]
From:
Shin-ichiro HARA <sinara@...>
Date:
2006-04-30 13:22:20 UTC
List:
ruby-dev #28609
原です。
>まつもと ゆきひろです
>|どちらもバグ扱いで 1.8.4 で直してもいいと思います。
>
>というわけで、原さんがコミットして下さるとうれしいなあ。
コミット権の件は後にして、パッチを流します。ほとんどドキュ
メントの差分ですが。
ところで、現在の 1.8.4 安定版スナップショットは、そのまま
で make test でエラーが3つ出ます。原因は util.c の strtod
のバグだと思います。1.9.0 の util.c の strtod にごっそり置
き換えると直ります。
更に、test/ruby/test_float.rb に次のコードを足すといいかも:
def test_divmod
assert_equal([2, 3.5], 11.5.divmod(4))
assert_equal([-3, -0.5], 11.5.divmod(-4))
assert_equal([-3, 0.5], (-11.5).divmod(4))
assert_equal([2, -3.5], (-11.5).divmod(-4))
end
def test_div
assert_equal(2, 11.5.div(4))
assert_equal(-3, 11.5.div(-4))
assert_equal(-3, (-11.5).div(4))
assert_equal(2, (-11.5).div(-4))
end
def test_modulo
assert_equal(3.5, 11.5.modulo(4))
assert_equal(-0.5, 11.5.modulo(-4))
assert_equal(0.5, (-11.5).modulo(4))
assert_equal(-3.5, (-11.5).modulo(-4))
end
def test_remainder
assert_equal(3.5, 11.5.remainder(4))
assert_equal(3.5, 11.5.remainder(-4))
assert_equal(-3.5, (-11.5).remainder(4))
assert_equal(-3.5, (-11.5).remainder(-4))
end
以下パッチです。
--- numeric.c.orig 2006-02-05 21:09:31.000000000 +0900
+++ numeric.c 2006-04-30 22:00:43.265625000 +0900
@@ -256,6 +256,8 @@
}
+static VALUE num_floor(VALUE num);
+
/*
* call-seq:
* num.div(numeric) => integer
@@ -269,7 +271,7 @@
num_div(x, y)
VALUE x, y;
{
- return rb_Integer(rb_funcall(x, '/', 1, y));
+ return num_floor(rb_funcall(x, '/', 1, y));
}
@@ -297,21 +299,21 @@
* ------+-----+---------------+---------+-------------+---------------
* -13 | -4 | 3, -1 | 3 | -1 | -1
* ------+-----+---------------+---------+-------------+---------------
- * 11.5 | 4 | 2.0, 3.5 | 2.875 | 3.5 | 3.5
+ * 11.5 | 4 | 2, 3.5 | 2.875 | 3.5 | 3.5
* ------+-----+---------------+---------+-------------+---------------
- * 11.5 | -4 | -3.0, -0.5 | -2.875 | -0.5 | 3.5
+ * 11.5 | -4 | -3, -0.5 | -2.875 | -0.5 | 3.5
* ------+-----+---------------+---------+-------------+---------------
- * -11.5 | 4 | -3.0 0.5 | -2.875 | 0.5 | -3.5
+ * -11.5 | 4 | -3, 0.5 | -2.875 | 0.5 | -3.5
* ------+-----+---------------+---------+-------------+---------------
- * -11.5 | -4 | 2.0 -3.5 | 2.875 | -3.5 | -3.5
+ * -11.5 | -4 | 2 -3.5 | 2.875 | -3.5 | -3.5
*
*
* Examples
* 11.divmod(3) #=> [3, 2]
* 11.divmod(-3) #=> [-4, -1]
- * 11.divmod(3.5) #=> [3.0, 0.5]
- * (-11).divmod(3.5) #=> [-4.0, 3.0]
- * (11.5).divmod(3.5) #=> [3.0, 1.0]
+ * 11.divmod(3.5) #=> [3, 0.5]
+ * (-11).divmod(3.5) #=> [-4, 3.0]
+ * (11.5).divmod(3.5) #=> [3, 1.0]
*/
static VALUE
@@ -715,7 +717,7 @@
flo_divmod(x, y)
VALUE x, y;
{
- double fy, div, mod;
+ double fy, div, mod, val;
volatile VALUE a, b;
switch (TYPE(y)) {
@@ -732,7 +734,13 @@
return rb_num_coerce_bin(x, y);
}
flodivmod(RFLOAT(x)->value, fy, &div, &mod);
- a = rb_float_new(div);
+ if (FIXABLE(div)) {
+ val = div;
+ a = LONG2FIX(val);
+ }
+ else {
+ a = rb_dbl2big(div);
+ }
b = rb_float_new(mod);
return rb_assoc_new(a, b);
}