summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--bignum.c13
-rw-r--r--internal.h1
-rw-r--r--numeric.c18
4 files changed, 28 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 67176ea4d9..8dd7b20f72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sat Apr 30 19:09:23 2016 Tanaka Akira <akr@fsij.org>
+
+ * numeric.c (int_lt): Define Integer#<.
+
+ * bignum.c (rb_big_lt): Don't define Bignum#<.
+ Renamed from big_lt.
+
+ * internal.h (rb_big_lt): Declared.
+
Sat Apr 30 18:44:05 2016 Tanaka Akira <akr@fsij.org>
* numeric.c (int_le): Define Integer#<=.
diff --git a/bignum.c b/bignum.c
index d81f601ba4..a13b0dc69e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -5460,16 +5460,8 @@ big_ge(VALUE x, VALUE y)
return big_op(x, y, big_op_ge);
}
-/*
- * call-seq:
- * big < real -> true or false
- *
- * Returns <code>true</code> if the value of <code>big</code> is
- * less than that of <code>real</code>.
- */
-
-static VALUE
-big_lt(VALUE x, VALUE y)
+VALUE
+rb_big_lt(VALUE x, VALUE y)
{
return big_op(x, y, big_op_lt);
}
@@ -6875,7 +6867,6 @@ Init_Bignum(void)
rb_define_method(rb_cBignum, "==", rb_big_eq, 1);
rb_define_method(rb_cBignum, ">", big_gt, 1);
rb_define_method(rb_cBignum, ">=", big_ge, 1);
- rb_define_method(rb_cBignum, "<", big_lt, 1);
rb_define_method(rb_cBignum, "===", rb_big_eq, 1);
#ifdef USE_GMP
diff --git a/internal.h b/internal.h
index e975838d3b..35e6019ef0 100644
--- a/internal.h
+++ b/internal.h
@@ -787,6 +787,7 @@ VALUE rb_big_abs(VALUE x);
VALUE rb_big_size_m(VALUE big);
VALUE rb_big_bit_length(VALUE big);
VALUE rb_big_remainder(VALUE x, VALUE y);
+VALUE rb_big_lt(VALUE x, VALUE y);
VALUE rb_big_le(VALUE x, VALUE y);
/* class.c */
diff --git a/numeric.c b/numeric.c
index 7b4ba01479..96bbfcc539 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3880,11 +3880,12 @@ fix_ge(VALUE x, VALUE y)
}
/*
+ * Document-method: Integer#<
* Document-method: Fixnum#<
* call-seq:
- * fix < real -> true or false
+ * int < real -> true or false
*
- * Returns +true+ if the value of +fix+ is less than that of +real+.
+ * Returns +true+ if the value of +int+ is less than that of +real+.
*/
static VALUE
@@ -3905,6 +3906,18 @@ fix_lt(VALUE x, VALUE y)
}
}
+static VALUE
+int_lt(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x)) {
+ return fix_lt(x, y);
+ }
+ else if (RB_TYPE_P(x, T_BIGNUM)) {
+ return rb_big_lt(x, y);
+ }
+ return Qnil;
+}
+
/*
* Document-method: Integer#<=
* Document-method: Fixnum#<=
@@ -4898,6 +4911,7 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "abs", int_abs, 0);
rb_define_method(rb_cInteger, "magnitude", int_abs, 0);
+ rb_define_method(rb_cInteger, "<", int_lt, 1);
rb_define_method(rb_cInteger, "<=", int_le, 1);
rb_define_method(rb_cFixnum, "==", fix_equal, 1);