diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-31 14:30:50 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-31 14:30:50 +0000 |
commit | 98454a6da81685775f663587f6df9670e0de0d9c (patch) | |
tree | 2c7b71880a246a0531f9b17e4373bb7aeff127a6 /object.c | |
parent | a6d38b8c39d2aa135920547439d729f7f51bfea6 (diff) | |
download | ruby-98454a6da81685775f663587f6df9670e0de0d9c.tar.gz |
* object.c (rb_to_float): replaced by to_flo definition from
math.c [ruby-dev:37668]
* math.c (Need_Float): use rb_to_float().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -2270,19 +2270,15 @@ rb_f_float(VALUE obj, VALUE arg) VALUE rb_to_float(VALUE val) { - VALUE v; - if (TYPE(val) == T_FLOAT) return val; - if (NIL_P(val)) { - rb_raise(rb_eTypeError, "can't convert nil into Float"); - } - v = convert_type(val, "Float", "to_f", Qtrue); - if (TYPE(v) != T_FLOAT) { - const char *cname = rb_obj_classname(val); - rb_raise(rb_eTypeError, "can't convert %s to Float (%s#to_f gives %s)", - cname, cname, rb_obj_classname(v)); - } - return v; + if (!rb_obj_is_kind_of(val, rb_cNumeric)) { + rb_raise(rb_eTypeError, "can't convert %s into Float", + NIL_P(val) ? "nil" : + val == Qtrue ? "true" : + val == Qfalse ? "false" : + rb_obj_classname(val)); + } + return rb_convert_type(val, T_FLOAT, "Float", "to_f"); } double |