summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-30 13:25:48 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-30 13:25:48 +0000
commitc0e3f62a757de9393ef363f2363a7daeddf86e7b (patch)
tree7c2121d26b408f4498a50f2f4e7ae48fa63a298b
parentf68760070127530a2f06205d3f71a594582fe7f7 (diff)
downloadruby-c0e3f62a757de9393ef363f2363a7daeddf86e7b.tar.gz
ruby-c0e3f62a757de9393ef363f2363a7daeddf86e7b.tar.xz
ruby-c0e3f62a757de9393ef363f2363a7daeddf86e7b.zip
* rational.c: added a static variable for nurat_to_f.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--rational.c4
-rw-r--r--test/ruby/test_complex.rb4
3 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b7104b05..8077531bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Aug 30 22:23:31 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * rational.c: added a static variable for nurat_to_f.
+
Sat Aug 30 20:05:41 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_open, rb_w32_read, rb_w32_write): fallback to
diff --git a/rational.c b/rational.c
index e0fe2a20c..44091081a 100644
--- a/rational.c
+++ b/rational.c
@@ -1020,6 +1020,8 @@ i_ilog2(VALUE x)
return q + r;
}
+static long ml;
+
static VALUE
nurat_to_f(VALUE self)
{
@@ -1465,6 +1467,8 @@ Init_Rational(void)
id_to_s = rb_intern("to_s");
id_truncate = rb_intern("truncate");
+ ml = (long)(log(DBL_MAX) / log(2.0) - 1);
+
rb_cRational = rb_define_class(RATIONAL_NAME, rb_cNumeric);
rb_define_alloc_func(rb_cRational, nurat_s_alloc);
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index 9f3f58eb8..145306ed2 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -283,12 +283,12 @@ class Complex_Test < Test::Unit::TestCase
assert_equal(Complex(1,1), Complex(1,1).nonzero?)
end
- def rect
+ def test_rect
assert_equal([1,2], Complex.rectangular(1,2).rectangular)
assert_equal([1,2], Complex.rect(1,2).rect)
end
- def polar
+ def test_polar
assert_equal([1,2], Complex.polar(1,2).polar)
end