summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c82
1 files changed, 9 insertions, 73 deletions
diff --git a/numeric.c b/numeric.c
index 45e17d2801..06351eca31 100644
--- a/numeric.c
+++ b/numeric.c
@@ -78,6 +78,9 @@ round(double x)
}
return x;
}
+#elif defined(__BEOS__)
+/* appears to be a bug in the BeOS headers */
+double round(double x);
#endif
static ID id_coerce, id_to_i, id_eq;
@@ -385,14 +388,14 @@ num_remainder(VALUE x, VALUE y)
/*
* call-seq:
- * num.scalar? -> true or false
+ * num.real? -> true or false
*
- * Returns <code>true</code> if <i>num</i> is an <code>Scalar</code>
+ * Returns <code>true</code> if <i>num</i> is a <code>Real</code>
* (i.e. non <code>Complex</code>).
*/
static VALUE
-num_scalar_p(VALUE num)
+num_real_p(VALUE num)
{
return Qtrue;
}
@@ -1948,66 +1951,6 @@ int_denominator(VALUE num)
/*
* call-seq:
- * Fixnum.induced_from(obj) => fixnum
- *
- * Convert <code>obj</code> to a Fixnum. Works with numeric parameters.
- * Also works with Symbols, but this is deprecated.
- */
-
-static VALUE
-rb_fix_induced_from(VALUE klass, VALUE x)
-{
- return rb_num2fix(x);
-}
-
-/*
- * call-seq:
- * Integer.induced_from(obj) => fixnum, bignum
- *
- * Convert <code>obj</code> to an Integer.
- */
-
-static VALUE
-rb_int_induced_from(VALUE klass, VALUE x)
-{
- switch (TYPE(x)) {
- case T_FIXNUM:
- case T_BIGNUM:
- return x;
- case T_FLOAT:
- case T_RATIONAL:
- return rb_funcall(x, id_to_i, 0);
- default:
- rb_raise(rb_eTypeError, "failed to convert %s into Integer",
- rb_obj_classname(x));
- }
-}
-
-/*
- * call-seq:
- * Float.induced_from(obj) => float
- *
- * Convert <code>obj</code> to a float.
- */
-
-static VALUE
-rb_flo_induced_from(VALUE klass, VALUE x)
-{
- switch (TYPE(x)) {
- case T_FIXNUM:
- case T_BIGNUM:
- case T_RATIONAL:
- return rb_funcall(x, rb_intern("to_f"), 0);
- case T_FLOAT:
- return x;
- default:
- rb_raise(rb_eTypeError, "failed to convert %s into Float",
- rb_obj_classname(x));
- }
-}
-
-/*
- * call-seq:
* -fix => integer
*
* Negates <code>fix</code> (which might return a Bignum).
@@ -2447,7 +2390,7 @@ fix_pow(VALUE x, VALUE y)
long b = FIX2LONG(y);
if (b < 0)
- return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
+ return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
if (b == 0) return INT2FIX(1);
if (b == 1) return x;
@@ -2468,7 +2411,7 @@ fix_pow(VALUE x, VALUE y)
case T_BIGNUM:
if (rb_funcall(y, '<', 1, INT2FIX(0)))
- return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
+ return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
if (a == 0) return INT2FIX(0);
if (a == 1) return INT2FIX(1);
@@ -3145,7 +3088,7 @@ Init_Numeric(void)
rb_define_method(rb_cNumeric, "magnitude", num_abs, 0);
rb_define_method(rb_cNumeric, "to_int", num_to_int, 0);
- rb_define_method(rb_cNumeric, "scalar?", num_scalar_p, 0);
+ rb_define_method(rb_cNumeric, "real?", num_real_p, 0);
rb_define_method(rb_cNumeric, "integer?", num_int_p, 0);
rb_define_method(rb_cNumeric, "zero?", num_zero_p, 0);
rb_define_method(rb_cNumeric, "nonzero?", num_nonzero_p, 0);
@@ -3169,7 +3112,6 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "upto", int_upto, 1);
rb_define_method(rb_cInteger, "downto", int_downto, 1);
rb_define_method(rb_cInteger, "times", int_dotimes, 0);
- rb_include_module(rb_cInteger, rb_mPrecision);
rb_define_method(rb_cInteger, "succ", int_succ, 0);
rb_define_method(rb_cInteger, "next", int_succ, 0);
rb_define_method(rb_cInteger, "pred", int_pred, 0);
@@ -3182,9 +3124,6 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "round", int_round, -1);
rb_cFixnum = rb_define_class("Fixnum", rb_cInteger);
- rb_include_module(rb_cFixnum, rb_mPrecision);
- rb_define_singleton_method(rb_cFixnum, "induced_from", rb_fix_induced_from, 1);
- rb_define_singleton_method(rb_cInteger, "induced_from", rb_int_induced_from, 1);
rb_define_method(rb_cInteger, "numerator", int_numerator, 0);
rb_define_method(rb_cInteger, "denominator", int_denominator, 0);
@@ -3234,9 +3173,6 @@ Init_Numeric(void)
rb_undef_alloc_func(rb_cFloat);
rb_undef_method(CLASS_OF(rb_cFloat), "new");
- rb_define_singleton_method(rb_cFloat, "induced_from", rb_flo_induced_from, 1);
- rb_include_module(rb_cFloat, rb_mPrecision);
-
rb_define_const(rb_cFloat, "ROUNDS", INT2FIX(FLT_ROUNDS));
rb_define_const(rb_cFloat, "RADIX", INT2FIX(FLT_RADIX));
rb_define_const(rb_cFloat, "MANT_DIG", INT2FIX(DBL_MANT_DIG));