aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-30 10:10:23 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-30 10:10:23 +0000
commit02dc27e88ebdc679a7767ea5f1cf46e92d043127 (patch)
tree344c1a19c809dd12279de2eb2b4c3848afd7e163 /numeric.c
parent60712bdc10947b53508ff6f5ab064e5462776968 (diff)
downloadruby-02dc27e88ebdc679a7767ea5f1cf46e92d043127.tar.gz
Define Integer#< instead of Bignum#<.
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c18
1 files changed, 16 insertions, 2 deletions
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);