ruby-changes:42108
From: mrkn <ko1@a...>
Date: Sat, 19 Mar 2016 00:02:54 +0900 (JST)
Subject: [ruby-changes:42108] mrkn:r54181 (trunk): * bignum.c (rb_big_to_f, Bignum#to_f): removed them because they are
mrkn 2016-03-19 00:02:45 +0900 (Sat, 19 Mar 2016) New Revision: 54181 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54181 Log: * 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. Modified files: trunk/ChangeLog trunk/bignum.c trunk/numeric.c Index: numeric.c =================================================================== --- numeric.c (revision 54180) +++ numeric.c (revision 54181) @@ -3767,7 +3767,8 @@ fix_aref(VALUE fix, VALUE idx) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3767 * 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) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3780 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)); } Index: bignum.c =================================================================== --- bignum.c (revision 54180) +++ bignum.c (revision 54181) @@ -5191,21 +5191,6 @@ rb_big2dbl(VALUE x) https://github.com/ruby/ruby/blob/trunk/bignum.c#L5191 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) https://github.com/ruby/ruby/blob/trunk/bignum.c#L7018 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); Index: ChangeLog =================================================================== --- ChangeLog (revision 54180) +++ ChangeLog (revision 54181) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Mar 19 00:00:00 2016 Kenta Murata <mrkn@m...> + + * 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@m...> * numeric.c (int_to_f, fix_to_f): rename fix_to_f to int_to_f, and add -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/