summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-30 10:26:17 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-30 10:26:17 +0000
commit289c3f40a1023889a0fe69c43487ca1762e209c6 (patch)
treea7a1697c16410bdceee64afb3e00bfefde8a3f1f
parent5576a93756eac174a2d0a9bd1a9c9ce66f749628 (diff)
downloadruby-289c3f40a1023889a0fe69c43487ca1762e209c6.tar.gz
Define Integer#>= instead of Bignum#>=.
* numeric.c (int_ge): Define Integer#>=. * bignum.c (rb_big_ge): Don't define Bignum#>=. Renamed from big_ge. * internal.h (rb_big_ge): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-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 685872e6b5..ff3a3f5733 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sat Apr 30 19:24:40 2016 Tanaka Akira <akr@fsij.org>
+
+ * numeric.c (int_ge): Define Integer#>=.
+
+ * bignum.c (rb_big_ge): Don't define Bignum#>=.
+ Renamed from big_ge.
+
+ * internal.h (rb_big_ge): Declared.
+
Sat Apr 30 19:20:40 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* doc/standard_library.rdoc: Remove obsoleted classes and modules.
diff --git a/bignum.c b/bignum.c
index a13b0dc69e..63cbb72ca9 100644
--- a/bignum.c
+++ b/bignum.c
@@ -5446,16 +5446,8 @@ big_gt(VALUE x, VALUE y)
return big_op(x, y, big_op_gt);
}
-/*
- * call-seq:
- * big >= real -> true or false
- *
- * Returns <code>true</code> if the value of <code>big</code> is
- * greater than or equal to that of <code>real</code>.
- */
-
-static VALUE
-big_ge(VALUE x, VALUE y)
+VALUE
+rb_big_ge(VALUE x, VALUE y)
{
return big_op(x, y, big_op_ge);
}
@@ -6866,7 +6858,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, "===", rb_big_eq, 1);
#ifdef USE_GMP
diff --git a/internal.h b/internal.h
index 35e6019ef0..a72f675026 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_ge(VALUE x, VALUE y);
VALUE rb_big_lt(VALUE x, VALUE y);
VALUE rb_big_le(VALUE x, VALUE y);
diff --git a/numeric.c b/numeric.c
index 96bbfcc539..9fe4379552 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3852,11 +3852,12 @@ fix_gt(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 greater than or equal to that of
+ * Returns +true+ if the value of +int+ is greater than or equal to that of
* +real+.
*/
@@ -3879,6 +3880,18 @@ fix_ge(VALUE x, VALUE y)
}
}
+static VALUE
+int_ge(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x)) {
+ return fix_ge(x, y);
+ }
+ else if (RB_TYPE_P(x, T_BIGNUM)) {
+ return rb_big_ge(x, y);
+ }
+ return Qnil;
+}
+
/*
* Document-method: Integer#<
* Document-method: Fixnum#<
@@ -4911,6 +4924,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_ge, 1);
rb_define_method(rb_cInteger, "<", int_lt, 1);
rb_define_method(rb_cInteger, "<=", int_le, 1);