aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-18 15:02:45 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-18 15:02:45 +0000
commit0d076fe4b3594f8bf4a229aa49c63563df28c899 (patch)
treed44311a8f4b88db9ac0b0961aaf096a8fe75c11d
parentbb00a5c11f008953c9cf863c0d8392d344bf3f2f (diff)
downloadruby-0d076fe4b3594f8bf4a229aa49c63563df28c899.tar.gz
* bignum.c (rb_big_to_f, Bignum#to_f): removed them because they are
unified with int_to_f and Integer#to_f. * numeric.c (int_to_f): treat Bignum values directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--bignum.c16
-rw-r--r--numeric.c6
3 files changed, 12 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 9830f370bb..1c5c2fc175 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Mar 19 00:00:00 2016 Kenta Murata <mrkn@mrkn.jp>
+
+ * bignum.c (rb_big_to_f, Bignum#to_f): removed them because they are
+ unified with int_to_f and Integer#to_f.
+
+ * numeric.c (int_to_f): treat Bignum values directly.
+
Fri Mar 18 23:41:00 2016 Kenta Murata <mrkn@mrkn.jp>
* numeric.c (int_to_f, fix_to_f): rename fix_to_f to int_to_f, and add
diff --git a/bignum.c b/bignum.c
index 67f8179271..2c241d1c56 100644
--- a/bignum.c
+++ b/bignum.c
@@ -5191,21 +5191,6 @@ rb_big2dbl(VALUE x)
return d;
}
-/*
- * call-seq:
- * big.to_f -> float
- *
- * Converts <i>big</i> to a <code>Float</code>. If <i>big</i> doesn't
- * fit in a <code>Float</code>, the result is infinity.
- *
- */
-
-static VALUE
-rb_big_to_f(VALUE x)
-{
- return DBL2NUM(rb_big2dbl(x));
-}
-
VALUE
rb_integer_float_cmp(VALUE x, VALUE y)
{
@@ -7033,7 +7018,6 @@ Init_Bignum(void)
rb_define_method(rb_cBignum, "<", big_lt, 1);
rb_define_method(rb_cBignum, "<=", big_le, 1);
rb_define_method(rb_cBignum, "===", rb_big_eq, 1);
- rb_define_method(rb_cBignum, "to_f", rb_big_to_f, 0);
rb_define_method(rb_cBignum, "abs", rb_big_abs, 0);
rb_define_method(rb_cBignum, "magnitude", rb_big_abs, 0);
rb_define_method(rb_cBignum, "size", rb_big_size, 0);
diff --git a/numeric.c b/numeric.c
index e0871049f7..99ad0882b8 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3767,7 +3767,8 @@ fix_aref(VALUE fix, VALUE idx)
* call-seq:
* int.to_f -> float
*
- * Converts +int+ to a Float.
+ * Converts +int+ to a +Float+. If +int+ doesn't fit in a +Float+,
+ * the result is infinity.
*
*/
@@ -3779,6 +3780,9 @@ int_to_f(VALUE num)
if (FIXNUM_P(num)) {
val = (double)FIX2LONG(num);
}
+ else if (RB_TYPE_P(num, T_BIGNUM)) {
+ val = rb_big2dbl(num);
+ }
else {
rb_raise(rb_eTypeError, "Unknown subclass for to_f: %s", rb_obj_classname(num));
}