diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-24 22:57:55 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-24 22:57:55 +0000 |
commit | 85e24491a6f2df6c764a743940651448e8d487b0 (patch) | |
tree | 6fd62bc314d98423e8c55aa97b262fbdd80f88b6 /numeric.c | |
parent | ee0d942ed9af59cefd7717ae456d76ebc5d2f6ee (diff) | |
download | ruby-85e24491a6f2df6c764a743940651448e8d487b0.tar.gz |
* numeric.c (int_round): Fix Integer#round [ruby-core:39096]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -3298,6 +3298,7 @@ int_round(int argc, VALUE* argv, VALUE num) { VALUE n, f, h, r; int ndigits; + ID op; if (argc == 0) return num; rb_scan_args(argc, argv, "1", &n); @@ -3324,7 +3325,8 @@ int_round(int argc, VALUE* argv, VALUE num) h = rb_funcall(f, '/', 1, INT2FIX(2)); r = rb_funcall(num, '%', 1, f); n = rb_funcall(num, '-', 1, r); - if (!RTEST(rb_funcall(r, '<', 1, h))) { + op = RTEST(rb_funcall(num, '<', 1, INT2FIX(0))) ? rb_intern("<=") : '<'; + if (!RTEST(rb_funcall(r, op, 1, h))) { n = rb_funcall(n, '+', 1, f); } return n; |