Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
cbe7a87c
Commit
cbe7a87c
authored
Mar 31, 2013
by
Masaki Muranaka
Committed by
Yukihiro "Matz" Matsumoto
Mar 31, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Integer.{floor,ceil,round,truncate} to mrblib/. For maintainability.
parent
dd56b936
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
11 deletions
+32
-11
mrblib/numeric.rb
mrblib/numeric.rb
+32
-0
src/numeric.c
src/numeric.c
+0
-11
No files found.
mrblib/numeric.rb
View file @
cbe7a87c
...
...
@@ -4,6 +4,14 @@
# ISO 15.2.8
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+.
...
...
@@ -18,6 +26,14 @@ class Integer
self
end
##
# Returns the receiver simply.
#
# ISO 15.2.8.3.17
def
floor
self
end
##
# Calls the given block +self+ times.
#
...
...
@@ -31,6 +47,22 @@ class Integer
self
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+.
...
...
src/numeric.c
View file @
cbe7a87c
...
...
@@ -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 */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment