diff options
| -rw-r--r-- | mrblib/numeric.rb | 32 | ||||
| -rw-r--r-- | src/numeric.c | 11 |
2 files changed, 32 insertions, 11 deletions
diff --git a/mrblib/numeric.rb b/mrblib/numeric.rb index 1d701b1fc..daa35c5d6 100644 --- a/mrblib/numeric.rb +++ b/mrblib/numeric.rb @@ -5,6 +5,14 @@ class Integer ## + # Returns the receiver simply. + # + # ISO 15.2.8.3.14 + def ceil + self + end + + ## # Calls the given block once for each Integer # from +self+ downto +num+. # @@ -19,6 +27,14 @@ class Integer end ## + # Returns the receiver simply. + # + # ISO 15.2.8.3.17 + def floor + self + end + + ## # Calls the given block +self+ times. # # ISO 15.2.8.3.22 @@ -32,6 +48,22 @@ class Integer end ## + # Returns the receiver simply. + # + # ISO 15.2.8.3.24 + def round + self + end + + ## + # Returns the receiver simply. + # + # ISO 15.2.8.3.26 + def truncate + self + end + + ## # Calls the given block once for each Integer # from +self+ upto +num+. # diff --git a/src/numeric.c b/src/numeric.c index e94647e5d..988c1c44a 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -716,17 +716,10 @@ num_round(mrb_state *mrb, mrb_value num) */ -/* 15.2.8.3.14 */ -/* 15.2.8.3.24 */ -/* 15.2.8.3.26 */ /* * call-seq: * int.to_i -> integer * int.to_int -> integer - * int.floor -> integer - * int.ceil -> integer - * int.round -> integer - * int.truncate -> integer * * As <i>int</i> is already an <code>Integer</code>, all these * methods simply return the receiver. @@ -1430,17 +1423,13 @@ mrb_init_numeric(mrb_state *mrb) mrb_define_method(mrb, fixnum, "^", fix_xor, ARGS_REQ(1)); /* 15.2.8.3.11 */ mrb_define_method(mrb, fixnum, "<<", fix_lshift, ARGS_REQ(1)); /* 15.2.8.3.12 */ mrb_define_method(mrb, fixnum, ">>", fix_rshift, ARGS_REQ(1)); /* 15.2.8.3.13 */ - mrb_define_method(mrb, fixnum, "ceil", int_to_i, ARGS_NONE()); /* 15.2.8.3.14 */ mrb_define_method(mrb, fixnum, "eql?", num_eql, ARGS_REQ(1)); /* 15.2.8.3.16 */ - mrb_define_method(mrb, fixnum, "floor", num_floor, ARGS_NONE()); /* 15.2.8.3.17 */ mrb_define_method(mrb, fixnum, "hash", flo_hash, ARGS_NONE()); /* 15.2.8.3.18 */ mrb_define_method(mrb, fixnum, "next", int_succ, ARGS_NONE()); /* 15.2.8.3.19 */ - mrb_define_method(mrb, fixnum, "round", num_round, ARGS_ANY()); /* 15.2.8.3.20 */ mrb_define_method(mrb, fixnum, "succ", fix_succ, ARGS_NONE()); /* 15.2.8.3.21 */ mrb_define_method(mrb, fixnum, "to_f", fix_to_f, ARGS_NONE()); /* 15.2.8.3.23 */ mrb_define_method(mrb, fixnum, "to_s", fix_to_s, ARGS_NONE()); /* 15.2.8.3.25 */ mrb_define_method(mrb, fixnum, "inspect", fix_to_s, ARGS_NONE()); - mrb_define_method(mrb, fixnum, "truncate", int_to_i, ARGS_NONE()); /* 15.2.8.3.26 */ mrb_define_method(mrb, fixnum, "divmod", fix_divmod, ARGS_REQ(1)); /* 15.2.8.3.30 (x) */ /* Float Class */ |
