summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--math.c15
-rw-r--r--object.c14
3 files changed, 22 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 63a99cbd17..80a4c1aae0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Dec 31 14:12:35 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_to_float): replaced by to_flo definition from
+ math.c [ruby-dev:37668]
+
+ * math.c (Need_Float): use rb_to_float().
+
Wed Dec 31 19:35:57 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* spec/README: follows the change of directory structure in rubyspec.
diff --git a/math.c b/math.c
index 3ac543150b..63a386360a 100644
--- a/math.c
+++ b/math.c
@@ -15,20 +15,7 @@
VALUE rb_mMath;
-static VALUE
-to_flo(VALUE x)
-{
- if (!rb_obj_is_kind_of(x, rb_cNumeric)) {
- rb_raise(rb_eTypeError, "can't convert %s into Float",
- NIL_P(x) ? "nil" :
- x == Qtrue ? "true" :
- x == Qfalse ? "false" :
- rb_obj_classname(x));
- }
- return rb_convert_type(x, T_FLOAT, "Float", "to_f");
-}
-
-#define Need_Float(x) (x) = to_flo(x)
+#define Need_Float(x) (x) = rb_to_float(x)
#define Need_Float2(x,y) do {\
Need_Float(x);\
Need_Float(y);\
diff --git a/object.c b/object.c
index 4f2fcb6def..aacf7ce43f 100644
--- a/object.c
+++ b/object.c
@@ -2267,6 +2267,20 @@ rb_f_float(VALUE obj, VALUE arg)
return rb_Float(arg);
}
+VALUE
+rb_to_float(VALUE val)
+{
+ if (TYPE(val) == T_FLOAT) return val;
+ 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
rb_num2dbl(VALUE val)
{