diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-18 15:02:45 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-18 15:02:45 +0000 |
commit | 2f92eee6158d948eba1dacde0c733bf4c1c9aea1 (patch) | |
tree | d44311a8f4b88db9ac0b0961aaf096a8fe75c11d /numeric.c | |
parent | dd828d4c7799f3d886d3be9a56fa4701b2887249 (diff) | |
download | ruby-2f92eee6158d948eba1dacde0c733bf4c1c9aea1.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
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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)); } |